title: unsupported media type application/x-www-form-urlencoded
body: <p>I'm getting this error all of a sudden:</p>
  
  <pre><code>21:28:14.345 [debug] ** (Plug.Parsers.UnsupportedMediaTypeError) unsupported media type application/x-www-fo
  rm-urlencoded
      (plug) lib/plug/parsers.ex:231: Plug.Parsers.ensure_accepted_mimes/4
      (api) lib/api/router.ex:1: Api.Router.plug_builder_call/2
      (api) lib/plug/debugger.ex:123: Api.Router.call/2
      (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
      (cowboy) /Users/Ben/Development/Projects/vepo/api/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
  </code></pre>
  
  <p>When making this network request:</p>
  
  <pre><code>Request URL:http://192.168.20.6:4000/products/?p_id=1&amp;s_id=1
  Request Method:PUT
  Status Code:415 Unsupported Media Type
  Remote Address:192.168.20.6:4000
  Referrer Policy:no-referrer-when-downgrade
  Response Headers
  view source
  cache-control:max-age=0, private, must-revalidate
  content-length:45284
  content-type:text/html; charset=utf-8
  date:Sun, 28 Jan 2018 08:40:36 GMT
  server:Cowboy
  Request Headers
  view source
  Accept:*/*
  Accept-Encoding:gzip, deflate
  Accept-Language:en-GB,en-US;q=0.9,en;q=0.8
  Connection:keep-alive
  Content-:application/json
  Content-Length:75
  Content-Type:application/x-www-form-urlencoded; charset=UTF-8
  Host:192.168.20.6:4000
  Origin:http://evil.com/
  Referer:http://localhost:8081/debugger-ui/debuggerWorker.js
  User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
  X-Requested-With:XMLHttpRequest
  Query String Parameters
  view source
  view URL encoded
  p_id:1
  s_id:1
  Form Data
  view source
  view URL encoded
  s_id:1
  p_id:1
  image:null
  price:2.53
  description:kcucufufi icif Gigiuyub
  </code></pre>
  
  <p>Code to send the request:</p>
  
  <pre><code>import { ajax } from 'rxjs/observable/dom/ajax'
  
  return ajax({
      body: action.payload,
      method: 'PUT',
      headers: { 'Content-': 'application/json' },
      url: `http://192.168.20.6:4000/products/?p_id=${
          action.payload.p_id
          }&amp;s_id=${action.payload.s_id}`
  }).map(response =&gt; updateEditProductInDbFulfilled(response))
      .catch(error =&gt; Observable.of(updateEditProductInDbRejected(error)))
  </code></pre>
  
  <p>I didn't actively change anything in my backend to not accept <code>x-www-form-urlencoded</code>, so why would this happen when it used to work?</p>
  
  <p>Is <code>x-www-form-urlencoded</code> bad? What is the best approach to successfully send my network request? Change my code sending the request or changing the backend somehow to accept the request?</p>
  
  <p>Backend is Elixir. </p>
  
  <p>This is how I added Plug.Parsers (In my router):</p>
  
  <pre><code>  if Mix.env == :dev do
      use Plug.Debugger
    end
    plug :match
    plug Plug.Parsers, parsers: [:json],
                     pass:  ["application/json"],
                     json_decoder: Poison
    plug :dispatch
  </code></pre>