rk dudi
Posts: 0
Joined: Thu May 23, 2013 4:27 pm

passing JSON Object in request parameter

How can I pass JSON object like one below as part of request Parameter:
{
"promptType": "listview",
"promptHeader":" This is a header ",
"promptText":"Hi welcome to my world. do you want to play",
"promptChoices":[
{"returnValue": "yes", "label": "sure"},
{"returnValue": "no", "label": "not interested"}],
"promptFooter":[
{"returnValue": "bye", "label": "bye"},
{"returnValue": "thanks", "label": "Great"}],
"respTimeout":"180",
}

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

passing JSON Object in request parameter

You should use local storage variable to pass values between services.

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

passing JSON Object in request parameter

The best solution is to define it in Request parameters or try using this: http://docs.appery.io/documentation/a...

rk dudi
Posts: 0
Joined: Thu May 23, 2013 4:27 pm

passing JSON Object in request parameter

I tried that but it also adds the requestParameter name when passing the object. For eg if the reqParameter name is say data then it ends up passing:
{"data":"localStorage JSON Object"} and also it adds a backslash char before every double quote value. is there an way to get rid of these 2 things.

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

passing JSON Object in request parameter

Working on it. Will update soon.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

passing JSON Object in request parameter

Hi,

Sorry for the delay. This can be done with JavaScript. In Request mapping click "Add JS" in front of the needed parameter and paste the following code:
codevar parametervalue = {
"promptType": "listview",
"promptHeader":" This is a header ",
"promptText":"Hi welcome to my world. do you want to play",
"promptChoices":[
{
"returnValue": "yes",
"label": "sure"
},
{
"returnValue": "no",
"label": "not interested"
}
],
"promptFooter":[
{
"returnValue": "bye",
"label": "bye"
},
{
"returnValue": "thanks",
"label": "Great"
}
],
"respTimeout":"180",
};

return JSON.stringify(parametervalue);/code
A string with JSON object will be sent to a Request parameter.

greg keys
Posts: 0
Joined: Wed Sep 25, 2013 4:32 am

passing JSON Object in request parameter

this works but when there are many different options in the object it can get overwhelming to track and implement

it would be a 1000x's simpler if you could add an option to request tab where we currently add new paramters to click a box to indicate if the request item is a json object

e.g. imagine that the following are request items in the tab

site_url mysite.com
q ________
key ________
reqObject _______ x return children as json
item1 _______
item2 _______
item3 _______
sub item1 ________
sub item2 ________

this would post something like the following (this is obviously not url encoded or grammatically correct but i hope you get the idea)

mysite.com/?q=_&key___&reqObject={"item1":" ", "item2":" " , "item3":{"sub item1":" ", "sub item2":" "}

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

passing JSON Object in request parameter

Hello! Thanks for an idea. I'll check if it's going to be implemented.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

passing JSON Object in request parameter

Hi,

It should be possible today, when you do POST request. You can define objects in Request tab.

greg keys
Posts: 0
Joined: Wed Sep 25, 2013 4:32 am

passing JSON Object in request parameter

Wow, I am really looking forward to that, this will allow me to condense about 50 services down to 2 and map the parameters so much easier

Return to “Issues”