Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending GET request parameters in body

Tags:

I have an API which accepts many parameters. Passing the values of the parameters will exceed the length of the URL Header.

I am using Postman client to pass the parameters in the body but this is not working any ideas on how to make this work.

The API accepts many parameters because the backend is legacy and is exposed as an API by a service bus.

like image 804
jhon.smith Avatar asked Feb 06 '17 13:02

jhon.smith


People also ask

Can you send a GET request with a body?

So, yes, you can send a body with GET, and no, it is never useful to do so. This is part of the layered design of HTTP/1.1 that will become clear again once the spec is partitioned (work in progress). Yes, you can send a request body with GET but it should not have any meaning.

CAN GET request have body parameters?

GET requests don't have a request body, so all parameters must appear in the URL or in a header. While the HTTP standard doesn't define a limit for how long URLs or headers can be, mostHTTP clients and servers have a practical limit somewhere between 2 kB and 8 kB.

How send parameters in HTTP GET request?

To use this function you just need to create two NameValueCollections holding your parameters and request headers. NameValueCollection QueryStringParameters = new NameValueCollection(); QueryStringParameters.


Video Answer


2 Answers

Older versions of Postman didn't allow you to send body data with get request.

Yet, if your server receives data as URL parameters you won't be able just to change the way of sending them and include them to the body (server won't accept them).

So if the length of parameters is indeed so big and the server indeed can receive the same data from body instead of from parameters then the Postman is just not the tool that you can use (maybe cURL is for you).

If your server allows to send data only as URL parameters and they are so long (more then 2000 chars What is the maximum length of a URL in different browsers?) then I think you have no chances to test this API.

UPDATE: new Version 7.20.1 now allows to send Body with GET request

like image 197
Denis Koreyba Avatar answered Sep 17 '22 19:09

Denis Koreyba


Workaround:

  1. Change the request type to POST.
  2. Set the value of your body
  3. Change request type to GET
  4. Send request and the body is included
like image 37
Steve Mullin Avatar answered Sep 21 '22 19:09

Steve Mullin