Forum Discussion

swetakumar's avatar
swetakumar
Occasional Contributor
4 years ago

how to mention JSON body in GET rest API

I am trying to find how to mention JSON body in GET rest API, but not successful. There are no parameters in the REST api request, just the JSON body. 

I can easily do it in Postman but struggling to find it in SoapUI pro or SoapUI. Attached the screenshot from Postman for the reference. 

  • PrathapR's avatar
    PrathapR
    Frequent Contributor

    Hey swetakumar 

     

    I don't think we can add request body for "GET". It should not have body by the definition, It should fetch data by using Query, Path parameters and Headers.

     

    If we have to pass request body,  need to add your REST resource(end point) as "POST" (If it's POST), then will see window to add request body.

     

     

    Thanks!

    • richie's avatar
      richie
      Community Hero
      Hi swetakumar,

      The reason why it appears you can submit a payload in a GET request in Postman is cos theres no context relative to the method selected in Postman whereas there is in soapui/soapui pro/readyapi!

      The RFCs that describe http methods are vague in places but are clear on this point that they dont expect payloads to be submitted using GET. If you want to retrieve data and pass a payload the RFCs suggest using POST instead.

      However, if you have the licensed version of soapui pro or readyapi you can make a config update to enable a payload field to appear for the GET method. There was another post recently where someone else asked the same question and one of the SmartBear staff respondef with the config entry change (i think it goes in the vmoptions file).

      The config change does NOT work for open source soapui but does work for pro/readyapi version according to what the SB staff memner stated in the post. If you have a search you should be able to find it.

      Ta

      Rich
      • swetakumar's avatar
        swetakumar
        Occasional Contributor

        I figured it out another solution. I can add a JSON body as a parameter in the value field with the Type 'Plain'.