Forum Discussion

New2API's avatar
New2API
Frequent Contributor
2 months ago

Getting rawReponse for a graphQL request using groovy

As a part tests data capture I would like to capture rawResponse of a graphQL test step.

For REST requests, we can use 

TestStep.testRequest.messageExchange.rawRequestData

messageExhange is not available for graphQL type. 

Any pointers?

TIA.

6 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    Where do you need? In groovy test step or in script assertion?

  • New2API's avatar
    New2API
    Frequent Contributor

    We are calling an eventHandler script - TestRunListener.afterStep. This step would excute after a REST or GraphQL step and get the test data for reporting purpose.

    We would like to get rawResponse that includes method, URL, headers used and body in the GQL call. we are able capture all the info except headers.

  • New2API's avatar
    New2API
    Frequent Contributor

    Yes, rawResponse give entire raw response. We are looking for raw request. Above would give only request body.

    • nmrao's avatar
      nmrao
      Champion Level 3

      The original question is answered. Is this an amendment?

  • New2API's avatar
    New2API
    Frequent Contributor

    My Question itself was incorrect - I meant rawRequest. Sorry for that.