1

Is it possible to use the request library in node to include a body for a get request? https://github.com/request/request#requestoptions-callback

It looks like the body option only works for POST/PUT/PATCH methods according to documentation. I was wondering if there was a known workaround for this. I know this is not conventional but the api that I will be hitting does accept a get request with a body and putting the data in query string is not an option because the url becomes too long. (I do not have the ability to implement api changes)

tetutato
  • 620
  • 5
  • 16
  • You might want to see this. http://stackoverflow.com/questions/978061/http-get-with-request-body Body in get request has no meaning – Umang Gupta Jul 28 '16 at 15:57
  • I have read the thread, and I know it goes against the spec. But the server is configured so that it does accept a GET body. – tetutato Jul 28 '16 at 18:26

1 Answers1

1

Turns out Node's request library does accept body in the get request although it doesn't mention it in the documentation. Just passing in options.body = {}, with options.json = true, worked great.

tetutato
  • 620
  • 5
  • 16