Body in GET requests

Originally posted by Voropaeva_Kris on April 18, 2019

Hello! How I can use the body with json-structure in GET requests? I haven’t MediaType place on GET requests so I haven’t place, which I can use for my request body.

Can I send body in GET response? How I can do it if it’s possible?

Originally posted by richie on April 18, 2019

Hey Voropaeva_Kris

Right - all the HTTP and w3c rules around the GET method indicate you don’t include a payload with a GET - you filter your GET based on the parameters on the request (URI/Template, Query and occasionally Header parms also).

REST rules apparently don’t define things as tightly as that - they just indicate use whatever method gets the job done, but as I say a GET request is filtered by the parms - not by a payload.

Someone else asked this quite recently on the board.

There are certain times that you have to switch the method from a GET to say a POST (if the query parms and values become too lengthy to be encoded) and this would allow you to create a payload with your GET request - cos essentially it wouldn’t be a GET anymore - but a POST.

Yes Postman does allow you to create a payload for a GET, but that’s only because there’s less field validation in Postman than SoapUI/ReadyAPI!

Including a GET on a payload has always been considered a faux pas in the places I’ve worked.

Are you sure you need to include a payload on yoru GET request? if I were you, I’d go back to the developers and query why they think you need a payload for a GET as this deviates from all the standard rules around GET requests - see w3c, etc.

Hence this is why SoapUI/ReadyAPI! doesn’t include any MediaType dropdown for the GET request - it was developed with the understanding you don’t include a payload with a GET request, so you don’t need to define the type!

Thanks,

richie