Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'GET' requests don't seem to include body #62

Open
sxh opened this issue May 22, 2019 · 3 comments
Open

'GET' requests don't seem to include body #62

sxh opened this issue May 22, 2019 · 3 comments

Comments

@sxh
Copy link

sxh commented May 22, 2019

I am integrating an application with ElasticSearch, and the search query API relies on sending the query in a JSON body attached to a get request (see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html for some examples).

I have been able to query the API this way from the command line using curl, and from Ruby using RestClient. When I try to do the same with Elm http the payload seems to get lost (I have checked the http request in Wireshark and compared it to the same request sent via Ruby).

The code used to set up the get request is shown below. The same code works as expected when I change the GET to POST, so I have a short term work around. Is dropping the payload on a GET request intended behaviour, or am I doing something wrong?

Http.request
{ method = "GET"
, headers = [ Http.header "Accept" "application/json" ]
, url = "https://(url here)/_search"
, body = Http.jsonBody jsonBodyValue
, expect = Http.expectJson SetProducts elasticSearchProductListDecoder
, timeout = Nothing
, tracker = Nothing
}

The send functions and returns a response, but the contents of the response is the same as when there is intentionally no query payload.

@Bernardoow
Copy link

I want send get with body too.

@speezepearson
Copy link

See this Elasticsearch issue for much discussion of this -- tldr, "the specs" and "the things people actually do" appear to be in conflict here. (The top comment also suggests a couple workarounds for clients that don't support GET-with-body.) I'm not an expert, but it sounds like the bottom line is "GET-with-body is discouraged and only sketchily supported and should be avoided."

So, I suspect that this issue will get tagged wontfix, given how opinionated Elm is in general ;)

@horriblename
Copy link

I feel like this should be mentioned in the docs even if it's a wontfix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants