Forum Discussion

eissaeva's avatar
eissaeva
Contributor
4 years ago

The content you are trying to view cannot be viewed as JSON

Hi

I am not able to view response in JSON

ReadyAPI 3.8.0

 

 

The tool shows views for all other formats successfully

 

 

  • nmrao's avatar
    nmrao
    4 years ago
    You need to report to your team and get it addressed if the services are developed by your team.
  • richie's avatar
    richie
    Community Hero
    Hey eissaeva,

    Can you confirm the Content-Type header of the response please?

    This will indicate the supported datatype of the response.

    Ta

    Rich
    • eissaeva's avatar
      eissaeva
      Contributor

      The content type of the response header is text/plain

      • richie's avatar
        richie
        Community Hero
        Hey eissaeva,

        Yep...."text/plain" Content-Type header value results in the payload being ignored by ReadyAPI's/SoapUI's json or xml parsers, which makes asserting on thr content awkward.

        If youre expecting the response to be wellformed Json or xml this sounds like a sloppy defect for dev to fix.

        However, depending on the app server endpoint youre hitting you can alter the datatype of the response by doing the following:

        Add an Accept HTTP header to the request which generates the json response thats comimg back with the text/plain Content-Type header. Ensure the value of the Accept header is either text/json or application/json (try both, one or even both might not work....depends on what your endpoint supports) Resubmit the request, view and check the results. Whats the Content-Type of the response? Do you now get content in the json response tab?

        This has worked numerous times for me when i had the same problem. It very rarely didnt work due to a restriction on the endpoint.

        Cheers

        Rich