Following is the response recieved from a REST service in JSON Format.
{
"data": [
{
"fieldname" : ["value1","value2"]
}
]
}
Following is my implementation for the above response :
1) Created BO_child with an attribute called "fieldname" of type Plain text.
2) Created BO_parent with "data" as its attribute of type BO_child
Records are getting created with null values.
How do I fix this issue?
How to handle array of values for a field in REST API resp?
-
- Posts: 130
- Joined: Tue Dec 03, 2013 10:19 pm
How to handle array of values for a field in REST API resp?
Last edited by bondicoffee on Wed Dec 11, 2019 6:57 pm, edited 1 time in total.
-
- Posts: 370
- Joined: Sat Apr 28, 2018 3:33 am
- Location: India
- Contact:
Re: How to handle array of values for a field in REST API re
Not sure why you are getting null because if its plain text it should dump json formatted data in plain text(may be length is small try 1000 in your column). Quickly looking at this if you want to get some data out of it in useful format there may be aware way to get it and if its too complex then you will have to parse the json using jquery or js I think.
Re: How to handle array of values for a field in REST API re
Your JSON is missing the last "}", or is that just a typo in your post.
What version of of AwareIM are you using?
I got this working (sort of) using build 2711.
I say sort of because only 1 BO_Child was created and the fieldname was populated with
value1^value2
I do not guarantee that I did not do something wrong myself, but I don't think that is what you want.
My guess is that AwareIM can not handle arrays in the format of
["value1","value2"]
I am no JSON expert, but I have only seen arrays like the following (which creates 2 BO_Child objects as expected)
{
"data": [
{
"fieldname": "value1"
},
{
"fieldname": "value2"
}
]
}
What version of of AwareIM are you using?
I got this working (sort of) using build 2711.
I say sort of because only 1 BO_Child was created and the fieldname was populated with
value1^value2
I do not guarantee that I did not do something wrong myself, but I don't think that is what you want.
My guess is that AwareIM can not handle arrays in the format of
["value1","value2"]
I am no JSON expert, but I have only seen arrays like the following (which creates 2 BO_Child objects as expected)
{
"data": [
{
"fieldname": "value1"
},
{
"fieldname": "value2"
}
]
}
Bob
-
- Posts: 130
- Joined: Tue Dec 03, 2013 10:19 pm
Re: How to handle array of values for a field in REST API re
Thank you Bob for looking into the response sample closely and pointing to missed '}'.
With regard to your question on the AwareIm version, I am using v8.4 Build 2709. I will try updating Awareim and verify if this works. Thanks
Is there a way in Awareim to collect whole JSON data in one attribute? I plan to update this JSON response using string manipulations and then create BO.
With regard to your question on the AwareIm version, I am using v8.4 Build 2709. I will try updating Awareim and verify if this works. Thanks
Is there a way in Awareim to collect whole JSON data in one attribute? I plan to update this JSON response using string manipulations and then create BO.
Re: How to handle array of values for a field in REST API re
Yes.bondicoffee wrote:Is there a way in Awareim to collect whole JSON data in one attribute? I plan to update this JSON response using string manipulations and then create BO.
On your intelligent BO, where you set the REST settings.
in the Reply section, check "Reply returned" and click on "Details..."
select "Write into object in Context" and select your desired BO from the Object drop down
and from the Attribute drop down, select the BO's attribute to write the data into.
Bob
-
- Posts: 130
- Joined: Tue Dec 03, 2013 10:19 pm
Re: How to handle array of values for a field in REST API re
Thanks Bob! Appreciate your quick response!
-
- Posts: 7526
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: How to handle array of values for a field in REST API re
Code: Select all
My guess is that AwareIM can not handle arrays in the format of
["value1","value2"]
Object.Attribute = "value1^value2"
But it shouldn't be null
Aware IM Support Team