Forum Discussion

JDM's avatar
JDM
New Contributor
3 years ago

Viewing or logging complete content of the incoming request to a REST MockService

Apologies for what's probably a very basic newbie question, but...

I'm using SoapUI to create a REST MockService, for the purpose of doing QA on a product I'm testing.  The product feature I need to test is (of course) that under certain conditions, it sends a REST request to a designated host in a designated format, gets the response, and acts accordingly.

Now to verify that this product feature is sending the correct data in the correct format, I need a way to have the SoapUI REST MockService show the complete content of the request:  the HTTP headers, their values, and of course the accompanying payload.  But the Message Log in the REST MockService window shows only the time an incoming request was received, and the endpoint it was directed to.  It does not show any of the actual request content.  The content doesn't seem to be shown in any of the other application logs either (SoapUI log, http log, etc.).

I tried using the OnRequest Script window to write the request content to the script log, but I can't find any articles detailing the properties associated with the httpRequest object.  The articles that would normally provide this information (see Section 2 of this page, https://www.soapui.org/docs/rest-testing-mocking/mock-service-scripting/) are dead links.

So bottom line, the question is:  How can I view the complete content (headers, payload, all of it) of the incoming requests to a REST MockService?

  • https://community.smartbear.com/t5/ReadyAPI-Questions/Mock-Service-mockRequest-requestContent-is-NULL-HTTP-PUT/td-p/42138

     

    After some searching I found two relevant answers in the above article.

    1. If everything were working you would be able to display this information using the script command log.info mockRequest.requestContent

    2. However not everything is working, this property returns null when processing a PUT request.  This looks to be a very very old bug that is yet to be fixed (going back to 2014).  But fortunately the same article's responses provide a workaround, a small block of script code that pulls the payload using a buffered reader object.

  • JDM's avatar
    JDM
    New Contributor

    https://community.smartbear.com/t5/ReadyAPI-Questions/Mock-Service-mockRequest-requestContent-is-NULL-HTTP-PUT/td-p/42138

     

    After some searching I found two relevant answers in the above article.

    1. If everything were working you would be able to display this information using the script command log.info mockRequest.requestContent

    2. However not everything is working, this property returns null when processing a PUT request.  This looks to be a very very old bug that is yet to be fixed (going back to 2014).  But fortunately the same article's responses provide a workaround, a small block of script code that pulls the payload using a buffered reader object.

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 3

    ** CHA EDIT - This does not answer the question.  I'd delete if I were able. **

     

    Hi,

     

    You can see exactly what SoapUI has sent by looking in the Raw tab of service request test step.

     

    Here is an example test request that shows the payload before the values have been added.

     

    Once the step runs, the Raw tab shows exactly what it sent.  E.g.

     

     

    • JDM's avatar
      JDM
      New Contributor

      That only works if I'm sending the request with SoapUI.  In this case though the request is coming in to the REST MockService from a different product (the one I'm trying to test).