scalaj-http icon indicating copy to clipboard operation
scalaj-http copied to clipboard

Send a get request with body

Open nikitap95 opened this issue 4 years ago • 3 comments

 Http("http://localhost:39180/api")
      .method("GET")
      .header("X", "test-app")
      .asString

is there a way to send a request body with a get request? My app functions in such way that it needs a request body to be sent..

nikitap95 avatar Jun 09 '20 11:06 nikitap95

@nikitap95 @hoffrocket I'm also looking for an answer on this too - any solutions or ideas? Something similar or equivalent to the Python version of request.get('url', json='body')

jyan33 avatar Apr 16 '21 11:04 jyan33

You should be able to do this: Http(url).postData(data).method("GET").asString

Not that it’s important for method to come after postData

hoffrocket avatar Apr 17 '21 15:04 hoffrocket

@hoffrocket this does not seem to work for GET. It seem to convert it into a POST when actually sending it

It works fine with other methods like DELETE though

alex-davies avatar Mar 31 '22 17:03 alex-davies