Page 1 of 2

passing JSON Object in request parameter

Posted: Fri May 24, 2013 8:58 pm
by rk dudi

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",
}


passing JSON Object in request parameter

Posted: Fri May 24, 2013 9:29 pm
by Igor

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


passing JSON Object in request parameter

Posted: Fri May 24, 2013 10:57 pm
by Igor

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


passing JSON Object in request parameter

Posted: Sat May 25, 2013 12:10 am
by rk dudi

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.


passing JSON Object in request parameter

Posted: Sat May 25, 2013 2:06 am
by Igor

Working on it. Will update soon.


passing JSON Object in request parameter

Posted: Mon May 27, 2013 8:32 am
by Kateryna Grynko

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.


passing JSON Object in request parameter

Posted: Wed Sep 25, 2013 4:32 am
by greg keys

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":" "}


passing JSON Object in request parameter

Posted: Wed Sep 25, 2013 8:45 am
by Maryna Brodina

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


passing JSON Object in request parameter

Posted: Wed Sep 25, 2013 3:50 pm
by Kateryna Grynko

Hi,

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


passing JSON Object in request parameter

Posted: Wed Sep 25, 2013 10:16 pm
by greg keys

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