How to allow user to select JSON or XML response from tRESTRequest
Can anyone explain to me how to get the tRESTRequest component to allow the user to specify whether to return either JSON or XML? I can get my service to return JSON by setting "Produces=JSON" and it returns XML by setting "Produces=XML". However, when I set "Produces=XML or JSON", I am only able to get XML response. I should add that I am accessing this from my browser (Chrome). So for example, I am going to http://localhost:8088/customers and I would like to know whether it is possible to add something to the end of that URL which would tell the service whether to return XML or JSON. Is it possible to do this through the URL? Thanks.
Re: How to allow user to select JSON or XML response from tRESTRequest
Shong, I tried your suggestion but it does not appear to be working as expected. I selected "JSON" form the "Accept Type" dropdown and I still get XML. I also set the header of "Accept" and "application/json" and I still get XML. Next, I discovered that if you set the value of "Accept Type" to "Any" and specify a header of "Accept" = "application/json", then you get JSON, but you can't get JSON if you select "JSON" from the dropdown. I have attached screenshots showing the following: 1. Select "Accept Type=JSON" and set header of "Accept = application/json". Output is XML. 2. Change "Accept Type=Any" and leave the same header. Output is JSON. Am I doing something wrong that is causing me to be unable to get JSON output when I select JSON from the dropdown?