Postman – Follow redirects with the original HTTP method and Content-Type

Problem

When you send a request with Postman and get back an unexpected 405 (Method Not Allowed) or 415 (Media Type Unsupported) error response, it may be due to Postman’s redirect behavior.

By default, Postman automatically follows redirect responses (3xx). If it’s a 301 or 302 redirect, it’ll redirect with a forced GET and won’t retain the Content-Type. This behavior can lead to these two types of error responses:

  • 405 (Method Not Allowed). Example: You do POST request, it redirects with a GET request and fails since GET isn’t allowed.
  • 415 (Media Type Unsupported). Example: You do a GET with a request body and Content-Type=application/json. It redirects without the Content-Type, which causes the request to fail.

Check Postman Console to see if a 301/302 redirect response is followed by an error response:

Postman Console showing a redirect (302) followed by an error (415) caused by doing the redirect as a forced GET
The Console is at the bottom of the Postman UI. Or you can open it as a separate window with View > Show Postman Console.

Solution

Option 1 – Turn off forced GET behavior

In the request, click Settings, and enable the Follow original HTTP Method setting:

Postman request - Settings tab. Enabled settings: Automatically follow redirects and Follow original HTTP method

Note: This is a per-request setting. You can’t set it globally for all requests (at least not in the current version).

This makes it follow 301/302 redirects using the original request HTTP method and it’ll retain the Content-Type. Therefore you won’t get the error responses caused by the forced GET behavior.

You can also disable automatically following redirects if you just want to see the redirect response (like if you’re just testing an endpoint to make sure it returns a redirect response).

Option 2 – Have your web API return a Preserve Method redirect

If you’re testing your own web API and run into this forced GET behavior, you may want to consider updating it to return a Preserve Method redirect (307/308) instead of a 301/302 redirect.

The standard convention is to return a 307/308 status code to indicate that the client should redirect using the original HTTP method. Postman handles Preserve Method redirects as expected (other clients do too – like HttpClient in .NET).

Of course, this is only a convention. You can define your API however you want. You can choose to simply return a 301 for all redirects if you want. Just be sure to explicitly state in your API documentation what redirect status codes you’re using and what the client should do with them.

Leave a Comment