Forum Discussion

gaganchawla's avatar
gaganchawla
Occasional Contributor
11 years ago

Change the reponse from content-type: text/html to text/json

Hi,
I am getting the response header for a rest based webservice shows the content-type as text/html even after I update the request header content-type: text/json,

Any advice on how to get the response in text/json format.

Cheers,
G

7 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    The response you receive will depend on the content-type your service is set to return. Perhaps a parameter in your request would indicate to the service that a text/json response should be return. It will depend on whether that option is implemented.

    Regards,

    Giscard
    SmartBear Support
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    This question sounds similar to this post:
    viewtopic.php?f=2&t=23494

    You need to override the Accept header and use value text/json in the request. See screen shot attached for example.


    Regards,
    Marcus
    SmartBear Support
  • gaganchawla's avatar
    gaganchawla
    Occasional Contributor
    Not working with me.

    I tried to follow the screenshot i.e. adding accept in the header section with value application json.

    Tried other combinations like adding two header parameters for Content-Type and Accept with value text/json (attached screenshot for this approach).

    Cheers,
    Gagan
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Are you getting an error when using Accept applicaton/json header? Do your service produce json as a response?



    Regards,
    Marcus
    SmartBear Support
  • gaganchawla's avatar
    gaganchawla
    Occasional Contributor
    The server do produce the result in application/json, I tried updating the headers via charles, a proxy dbugging tool, and it worked, but not with SoapUI.

    I am not getting an error it just keep displaying the same headers text/html in the response.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Then maybe something is not correct with the url you are using SoapUI Pro. If you are able to get json returned outside of SoapUI Pro check the request you are doing such as the headers and url versus the request you see in SoapUI Pro. I am able to get json returned with no problem using the Google Maps REST API in SoapUI Pro.




    Regards,
    Marcus
    SmartBear Support