HTTP 415 - Unsupported Media Type with proper content type

Not applicable

Hi everyone!

Apigee is sending 415 response for any POST request, and I'm having hard time to debug what is going wrong. I'm passing Content-Type: application/json as suggested in related question, but it doesn't make any difference. In the same time, if I set content type to multipart-form, Apigee consider it as valid request, but body of that request becomes empty.

Is there a way to get some insights why it is happening?

What Apigee consider as supported content type?

Is there a way to tell Apigee which content type is correct?

Sample of my request:

{
  "method": "POST",
  "url": "https://<host>/v1/auth",
  "headers": {
    "ApiKey": "<apikey>",
    "Content-Type": "application/json",
    "Accept": "application/json"
  },
  "data": "{\"accountId\": 1}"
}
Sample of response:
{
  "pragma": "no-cache",
  "date": "Wed, 14 Feb 2018 15:15:11 GMT",
  "cache-control": "no-cache",
  "connection": "close",
  "content-length": "18",
  "content-type": "text/plain",
  "status": 415
}
0 1 18.4K
1 REPLY 1

Hi

I don't have the answer for you but I might be able to provide some clues.

  1. You say you are receiving a 415 response code "from Apigee". What part of Apigee Edge? It looks like the endpoint you are tickling is https://<host>/v1/auth. Is that a custom endpoint that will reach an Apigee Edge API Proxy you have created? If so, what policies run there?
    If it is an oAuthV2 policy, something that will generate a token, then.... it is likely that the policy itself is returning the 415 response code. But I am only guessing.
  2. You are showing the response as a JSON payload. Where is that coming from ? How are you invoking the endpoint, and how do you get those payloads? Normally the response code is not embedded into a JSON payload , but is sent at the beginning of the HTTP response. I am more accustomed to seeing the response formatted this way:

    HTTP/1.1 200 OK
    Date: Thu, 15 Feb 2018 20:27:57 GMT
    Content-Type: application/json
    Content-Length: 225
    Connection: keep-alive
    
    
    {
      "timed_out": false,
      "_shards": {
        "total": 12,
        "successful": 12,
        "failed": 0
      },
      "hits": {
        "total": 0,
        "max_score": null,
        "hits": []
      },
      "stamp": "reformatted at 2018-02-15T20:27:57.425Z"
    }
  3. you wrote, "What Apigee consider as supported content type?"
    And the answer to that is, "it depends on your configuration." Here I am assuming that by "Apigee" you are referring to a custom-built API Proxy that YOU have configured and deployed into an Apigee Edge org+env. In that case, YOU control all of the behavior of the proxy, and YOU control what the proxy will consider to be "valid" as regards various combinations of content-type and method and path and so on. Maybe you could show the configuration of your API Proxy endpoint?