Ran through README, API is servering XML
Response for http://127.0.0.1:3000/api/accounts is:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<result>
<__persisted>true</__persisted>
<__cachedRelations/>
<__data>
<email>[email protected]</email>
<created>2014-10-23T23:18:08.207Z</created>
<modified>2014-10-23T23:18:08.207Z</modified>
<id>1</id>
</__data>
<__dataSource></__dataSource>
<__strict>false</__strict>
</result>
<result>
<__persisted>true</__persisted>
<__cachedRelations/>
<__data>
<email>[email protected]</email>
<created>2014-10-23T23:18:08.207Z</created>
<modified>2014-10-23T23:18:08.207Z</modified>
<id>2</id>
</__data>
<__dataSource></__dataSource>
<__strict>false</__strict>
</result>
</response>
I don't see where to specify response data type and from http://docs.strongloop.com/display/LB/Exposing+models+over+a+REST+API it states specirically:
The response format for all requests is a JSON object [...]
Why is it returning XML? How do I get it to return JSON?
@CrabDude which connector did you use? @raymondfeng @ritch @bajtos any idea why xml is being returned?
@superkhau postgres & accountDB
FWIW, I used & aborted slc loopback:model [...] a couple times b/c I didn't read the prompts. I had to manually cleanup the models by deleting from /common/models and model-config.json.
@CrabDude i will try to reproduce it using the postgres connector and get back to you. can you provide a bit more info? are you on windows/mac/linux? slc version? how are you making the request to test? like are you using curl?
Hmmm.... Looks like hitting it from the browser is the problem since it's sending
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
curl returns JSON.
Sorry, I was confused because I didn't see XML mentioned anywhere in the docs and most demo REST APIs don't come with proper Accept header support.
In other words, it looked like it was broken because you were doing the right thing where other demos typically don't. ;)
Is there a url override for the response format?
Thanks for the prompt responses!
XML Support is brand new... It is odd that you are getting XML instead of JSON... I'd like to change that since I personally hate XML.
On Thu, Oct 23, 2014 at 4:47 PM, Adam Crabtree [email protected] wrote:
Hmmm.... Looks like hitting it from the browser is the problem since it's sending
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
curl returns JSON.
Sorry, I was confused because I didn't see XML mentioned anywhere in the docs and most demo REST APIs don't come with proper Accept header support.
In other words, it looked like it was broken because you were doing the right thing where other demos typically don't. ;)
Is there a url override for the response format?
Thanks for the prompt responses!
— Reply to this email directly or view it on GitHub https://github.com/strongloop/loopback-example-database/issues/17#issuecomment-60326482 .
StrongLoop http://strongloop.com/* makes it easy to develop APIs http://strongloop.com/mobile-application-development/loopback/ in Node, plus get DevOps capabilities http://strongloop.com/node-js-performance/strongops/ like monitoring, debugging and clustering*.
I'd like to change that since I personally hate XML.
Likewise, which is the reason for my posting the issue, however...
XML Support is brand new... It is odd that you are getting XML instead of
JSON...
In my last comment, I was pointing out that I believe it's actually expected since the browser is sending the Accept:application/xml header and not the Accept:application/json. Also, curling confirmed that application/json is the default when an Accept header is absent.
Thanks again.