Page 1 of 1

List is empty after invoking REST service

Posted: Thu Nov 07, 2013 3:50 am
by kuvalda

Hello, I have create a test REST service that returns the following array result as was tested using appery.io service test:

[
{
"name":"abc"
},
{
"name":"def"
}
]

next I mapped service response to a list component on the page, such that $ is mapped to list item (for some reason I am not able to map it directly to the list component?) and 'name' is mapped to list item - text property. See screen shot:
Image

However when I test my app and execute the service in the browser the list component doesn't show up at all??? I am able to see that the service is executed successfully and correct response is returned using Chrome - developer tools.

This service is using jsonp as data type. I also tried using json and appery.io proxy but that leads to errors when invoking the service.

Here is a link to my test page: http://appery.io/app/mobile-frame?src...

thanks for your help!


List is empty after invoking REST service

Posted: Thu Nov 07, 2013 6:53 am
by Maryna Brodina

Hello! Working on it.


List is empty after invoking REST service

Posted: Thu Nov 07, 2013 12:34 pm
by Maryna Brodina

Hi, in response you have regular json, but there should be json wrapped in callback function http://en.wikipedia.org/wiki/JSONP. Server response should look like this prejQuery18203998429486528039_1383826914110([{"name":"qr_dealers"},{"name":"qr_geo"},{"name":"qr_inventory"},{"name":"qr_log"},{"name":"qr_offer_inventory"},{"name":"qr_offers"},{"name":"qr_options"},{"name":"qr_redemptions"},{"name":"qr_rule_inventory"},{"name":"qr_rules"},{"name":"qr_shorturl"},{"name":"qr_urls"},{"name":"qr_user"}]);/pre Function name (in this example it's jQuery18203998429486528039_1383826914110) server retrieves in get parameter of callback request. So you need to change server code the way it wraps response in callback function.


List is empty after invoking REST service

Posted: Thu Nov 07, 2013 2:52 pm
by kuvalda

Thanks Maryna, this makes sense.

How can I pass the callback function as a request parameter? The name of the callback function seems to be auto generated for every request or does it stay the same every time?


List is empty after invoking REST service

Posted: Thu Nov 07, 2013 3:04 pm
by Maryna Brodina

You don't need to generate it - jQuery will do it for you. You need just change the code on server.


List is empty after invoking REST service

Posted: Thu Nov 07, 2013 5:06 pm
by kuvalda

Thanks Maryna. This works I just had to change the server code to echo the callback function.

Also, I should be able to test the service using a regular JSON data type with appery.io proxy... however I am getting '403 Forbidden' error as status code and no response returned.

can you please advise?


List is empty after invoking REST service

Posted: Thu Nov 07, 2013 8:35 pm
by Kateryna Grynko

Hi,

What site do you send request to? Please post a screenshot with the error.


List is empty after invoking REST service

Posted: Thu Nov 07, 2013 9:52 pm
by kuvalda

Hi, here is a screen shot of the error using Chrome - developer tools

Image


List is empty after invoking REST service

Posted: Fri Nov 08, 2013 9:51 am
by Oleg Danchenkov

Yes. I have reproduced this issue with your url. Probably some problems with your server settings. But I cant say for sure. We need some time for research.


List is empty after invoking REST service

Posted: Fri Nov 08, 2013 4:49 pm
by Kateryna Grynko

Hi,

In your example with TestService try changing 'jsonp' to 'json' and tick 'Use Appery.io Proxy'. This works for us. In your example you use the following URL: http://scaniqa.aws.af.cm/hello/world