kuvalda
Posts: 0
Joined: Thu Oct 24, 2013 2:15 pm

List is empty after invoking REST service

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!

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

List is empty after invoking REST service

Hello! Working on it.

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

List is empty after invoking REST service

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.

kuvalda
Posts: 0
Joined: Thu Oct 24, 2013 2:15 pm

List is empty after invoking REST service

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?

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

List is empty after invoking REST service

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

kuvalda
Posts: 0
Joined: Thu Oct 24, 2013 2:15 pm

List is empty after invoking REST service

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?

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

List is empty after invoking REST service

Hi,

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

kuvalda
Posts: 0
Joined: Thu Oct 24, 2013 2:15 pm

List is empty after invoking REST service

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

Image

Oleg Danchenkov
Posts: 0
Joined: Tue Apr 30, 2013 5:51 pm

List is empty after invoking REST service

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.

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

List is empty after invoking REST service

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

Return to “Issues”