Forum Discussion

LouLoglisci's avatar
LouLoglisci
Regular Visitor
3 years ago
Solved

outline

how come my outline view of a response is not in tree format?

This is the Raw view:

 

HTTP/1.1 400 Bad Request
Date: Sat, 02 Apr 2022 14:42:38 GMT
Content-Type: text/plain; charset=utf-8
Server: Kestrel
Transfer-Encoding: chunked

{"JsonOk":{"trResult":false,"errorCode":"","trMsg":"Bearer token is missing from header.","NoEx":false,"exMsg":"Message Value Error: Bearer token is missing from header.","exType":"Value","accessToken":"","refreshToken":""}}

 

This is the outline view: 

 

 

  • Hey LouLoglisci,

    The problem is your Content-Type header is telling ReadyAPI "this is just text, this isnt json, so dont bother parsing it as json"

    Your Content-Type header is text/plain

    Hence the reason youre not able to assert on or do anything with the content of the payload.

    To be honest i see this every so often and its down to sloppy dev (and either the dev hasnt noticed or doesnt understand the significance of having the correct datatype in the header) or its a defect and hopefully it'll change.

    It needs to be either 'text/json; charset=utf-8' or 'application/json; charset=utf-8'.

    Well in fact it only needs to be text/json or application/json for it to work....i added the charset flag cos its what youve already got in your header.

    You have a couple of choices.

    1. Raise it with the devs and say ReadyAPI isnt treating it as you need to test it....its a json payload so youd expect the Content-Type header to be correct

    Or

    2. You can split the json string out into a separate temp property and then grab the specific name/value pairs via a second property (quite fiddly, but is possible cos ive done it before when ive had to assert on CDATA wrapped xml......CDATA wrapped xml is also ignored by the parser, so you need to do the temp property option to handle it)

    Or

    3. Try using event handlers to change the Content-Type header from text/plain to text/json or application/json and then youll be able to assert on the content)

    Option 3 requires groovyscript.
    Option 2 doesnt need groovyscript (but it helps), but if you google "asserting on CDATA in ReadyAPI" this brings up the page that will you enable you to follow the temporary property option to assert on your content.
    Option1 is the best option as its technically correct and requires no work from yourself with only a small code change by dev.

    If you wanna go with option2 or option3 and get stuck, just post back and we can sort it out. However, theres no point putting in the effort as dev should sort this.

    Cheers,

    Rich

1 Reply

  • richie's avatar
    richie
    Community Hero
    Hey LouLoglisci,

    The problem is your Content-Type header is telling ReadyAPI "this is just text, this isnt json, so dont bother parsing it as json"

    Your Content-Type header is text/plain

    Hence the reason youre not able to assert on or do anything with the content of the payload.

    To be honest i see this every so often and its down to sloppy dev (and either the dev hasnt noticed or doesnt understand the significance of having the correct datatype in the header) or its a defect and hopefully it'll change.

    It needs to be either 'text/json; charset=utf-8' or 'application/json; charset=utf-8'.

    Well in fact it only needs to be text/json or application/json for it to work....i added the charset flag cos its what youve already got in your header.

    You have a couple of choices.

    1. Raise it with the devs and say ReadyAPI isnt treating it as you need to test it....its a json payload so youd expect the Content-Type header to be correct

    Or

    2. You can split the json string out into a separate temp property and then grab the specific name/value pairs via a second property (quite fiddly, but is possible cos ive done it before when ive had to assert on CDATA wrapped xml......CDATA wrapped xml is also ignored by the parser, so you need to do the temp property option to handle it)

    Or

    3. Try using event handlers to change the Content-Type header from text/plain to text/json or application/json and then youll be able to assert on the content)

    Option 3 requires groovyscript.
    Option 2 doesnt need groovyscript (but it helps), but if you google "asserting on CDATA in ReadyAPI" this brings up the page that will you enable you to follow the temporary property option to assert on your content.
    Option1 is the best option as its technically correct and requires no work from yourself with only a small code change by dev.

    If you wanna go with option2 or option3 and get stuck, just post back and we can sort it out. However, theres no point putting in the effort as dev should sort this.

    Cheers,

    Rich