You need to sign in to do that
Don't have an account?
eswari
URGENT: Get the response data as json format
Hi,
I am making a REST Service call from my apex class which returns the data in xml format.
I want the data to be in json format instead of xml.
Is there any way to get the data as json by specifying any property or something?
Hi,
Instead of using the format parameter, you can also specify the returned format in an accept-request header using as below
req.setHeader('Accept', 'application/json;charset=UTF-8'); // When you use setMethod as 'GET' To get response in xml format.
req.setHeader('Content-Type', 'text/json;charset=UTF-8'); // When you use setMethod as 'POST' To get response in xml format.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.