In this case, I am using Drupal 7 with Services 3.x.
It's just one of those things I guess you don't lean until you need to, and I never had yet. It was difficult to find the info though.
Here is the scenario:
- You are calling a web service using JSON as the Content Type.
- You are getting back an XML response.
- You want to get back a JSON response.
Here's what you need to do.
Goto your services

Select "Edit Server"
Make sure the response formatter "json" is selected. It may already be.
Now in your JSON REQUEST, add the following header:
Accept = "application/json"
For some reason, Drupal was returning the response in XML format by default, I don't know why, but adding this header to the request immediately gave me back a JSON response.
No comments:
Post a Comment