Home  >  Q&A  >  body text

"The media type in the POST request is not supported (415 error)"

<p>Does anyone know what causes error 415 (unsupported media type)? Thank you</p> <pre class="brush:php;toolbar:false;">createArticleOld : async ({ commit, dispatch }, data) => { let added = await dispatch('authorizedPostOld', { action: 'article', data, headers: { 'Content-Type': 'application/json-patch json', 'Accept': 'application/json-patch json', }, } ) console.log(added) commit('ADD_ARTICLE', added) },</pre></p>
P粉668019339P粉668019339420 days ago475

reply all(1)I'll reply

  • P粉455093123

    P粉4550931232023-08-26 10:02:04

    Typically, HTTP response status code 415 tells you that the data you sent is in a format that the server does not accept, as briefly described here: here.

    So to solve the problem you need to find out the format the server expects to receive the data in, and send it in that format. The easiest way is to check your server's documentation (or ask the developer).

    If you examine the raw response returned by the browser (or perform the same request via a tool like cURL or Postman), you may find some clues there about the formats accepted by the endpoint or the specific issue causing the incorrect response.

    Of course, this requires the developer of the server to implement HTTP status codes correctly, and they may have made a mistake. As a complete guess, given that you set the Accept header, the server is probably trying to tell you that it can't give you a response in the "application/json-patch json" format, although that should give you a 406 .

    reply
    0
  • Cancelreply