question

DianaHuang-0252 avatar image
0 Votes"
DianaHuang-0252 asked DianaHuang-0252 commented

User Agent string in Content-Type header causing 415

Hi all,

Our codebase uses an sdk that appends the user agent string to the Content-Type of the http request. (Content-Type: application/json-patch+json+libhttp/8.03+(PlayStation+4))

When we make a POST to our IIS service website, we receive a 415 - Unsupported Media Type. If the user agent string is removed from Content-Type, we receive the expected 200 OK.

We have tried working around this by adding a MIME type to the IIS website config. We tried several extensions that should work for basic strings that weren't already being used (.log, .asc) with the value being "libhttp/8.03+(PlayStation+4)". But we still receive 415s.

Is there a known way to handle this? Our IIS version is 8.5.

windows-server-iis
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

HuryShenMSFT-3800 avatar image
1 Vote"
HuryShenMSFT-3800 answered DianaHuang-0252 commented

In my opinion, I don't think we can solve this problem according to add more items in MIME type of IIS.

We can add a new "fileExtension" in MIME type and set its "mimeType" to allow IIS recognize this kind of file extension. But we can't add a new "mimeType" to ask IIS recognize this kind of "mimeType". In other words, we can input anything(eg .aa .bb .cc) for the value of "fileExtension", but we can't use a nonexistent type for the value of "mimeType".

<mimeMap fileExtension="anything(eg .aa .bb .cc)" mimeType="we can just use common MIME types" />

The operation "append user-agent to content-type" which you mentioned in your question is strange. I think you'd better set the user-agent in the header of the http request in your code instead of append it to content-type.


If the answer is helpful, please click "Accept Answer" and upvote it.


Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the clear explanation! I agree that the right course may be to ask the SDK developers to adjust it so their http request places the user agent in the appropriate header.

0 Votes 0 ·