Hi, confused user here.
The OP is making a PUT request, and their fix was simple enough (even if @crashandburnuk very correctly commented that this is not really very intuitive).
I have also found out that things are a bit easier when making a POST request. In that case, Postman does respect the Content-Type
header. At least, thatās what Iāve found out. Thatās true even if the payload on the body is empty (length zero), which technically would mean that the Content-Type
would not apply (on the other hand, one might argue ad infinitum that a payload of zero bytes can have any Content-Type
ā since zero bytes is a valid length for a payload )
Nowā¦ how to accomplish the same with a GET requestā¦?
For GET, Postman allows a payload to be sent (which is not forbidden) and so it follows that it should be possible to set the Content-Type
as well. However, Postman (as well as others, such as ā allegedly ā .NET) does not allow that type of configuration.
curl
has no problem whatsoever, itās totally agnostic to what you do or donāt do, so long as itās not explicitly forbidden by the specs.
According to the specs, if one wants that the reply to a GET request to explicitly be in, say, JSON or XML (as opposed to the default, whatever that might be), one ought to place Accept
headers indicating the content-type preference. Sadly, though, many (most?) APIs simply couldnāt care less about Accept
headers, and just send whatever the server wants ā unless the request does, indeed, specify Content-Text
ā¦ which is not possible to configure in Postman for GET requests.
It seems to me that there is a slight inconsistency on Postmanās interpretation of the specs. Either GET cannot have a payload, and then the request body should be greyed out (and no Content-Type
header is sent); or, like curl
does, if a payload is allowed with GET, then setting the Content-Type
should be possible, too ā even if the body is empty!
Iām not an expert in interpreting the specs, mind you. Exchanging a few cool posts with Tim Berners-Lee when he announced his ācool new ideaā in the early 1990s does not make me an āauthorityā
(not really worth taking a look, but hereās the link to my public workspace)