haskell-servant / servant-elm

Automatically derive Elm functions to query servant webservices
BSD 3-Clause "New" or "Revised" License
164 stars 48 forks source link

elm-0.18: Content-Type is set twice for JSON #19

Closed jb55 closed 7 years ago

jb55 commented 7 years ago

It looks like Http already adds Content-Type: application/json when using jsonBody:

https://github.com/elm-lang/http/blob/99c00a2dac21dda1d4954515c79e6f28e431573f/src/Http.elm#L287-L292

The generated code also adds it, causing application/json to appear twice in the Content-Type header. This causes servant to reject the request with 415: Unsupported Media Type

My current workaround:

find frontend/src/Generated -name '*.elm' -exec \
  sed -i 's/Http.header "Content-Type" "application\/json"//' {} \;
jb55 commented 7 years ago

Fixed in d758f93

kgashok commented 7 years ago

This problem had me going in circles for almost ~2 hours until I found this issue by googling. Some sample code would be much appreciated by Elm and HTTP API noobs like me.