1

I have my own webshop set up with a payment provider and to finalize the buy they send me a post to a page with some data for me to acknowledge the order.

The problem is that when they do the request it returns a 406 error for them. This is what i could find in the logs

The request was rejected because it contained an Accept header for a MIME type that is not supported for the requested file extension.

Content-Type: application/json
Connection: keep-alive
Content-Type: text/plain;charset=UTF-8

What do i need to do for this post not get rejected in asp.net. I am using a global.asax for routing purposes. I have added the mimetype in web.config as so

<mimeMap fileExtension=".json" mimeType="application/json" />

But i figure that doesnt make it an acceptable headertype?

EDIT This is the post they send

connection  close
accept-encoding gzip,deflate
user-agent  Apache-HttpClient/4.5.7 (Java/11.0.13)
host    webhook.site
content-length  2
request-timeout 6300
klarna-client-timeout   6300
klarna-idempotency-key  xxx
klarna-originator-user  
klarna-originator-source    
klarna-correlation-id   xxx
content-type    application/json;charset=UTF-8
Jimmy
  • 275
  • 2
  • 6
  • 27
  • I suspect you need to look at the request headers - specifically the `accept` header. – Richard Deeming Nov 05 '21 at 13:30
  • As far as i can tell they dont send an accept. What do i need to accept specifically? Check my edit for the post they send – Jimmy Nov 05 '21 at 13:35
  • As a side note i have tried using postman and sending the data that way and it works fine. Its their specific post i cannot get to work – Jimmy Nov 05 '21 at 13:37
  • Maybe it's because there's no `accept` header? [RFC7231](https://www.rfc-editor.org/rfc/rfc7231.html#section-5.3.2) says it should be treated the same as `accept: */*`, but maybe IIS doesn't implement that properly? – Richard Deeming Nov 05 '21 at 13:49
  • Have you enabled the "static content" feature for IIS? [IIS 10 ASP.NET service.svc error 406 Not Acceptable help](https://forums.iis.net/t/1252219.aspx?IIS+10+ASP+NET+service+svc+error+406+Not+Acceptable+help) – Richard Deeming Nov 05 '21 at 13:51
  • Yes, it is enabled and i have added .json. – Jimmy Nov 05 '21 at 14:53

1 Answers1

0

I found my solution.

It seems as my webserver has a blacklist of user-agents. They think the POST has a "to generic" user-agent. Witch caused it to return a 406 error.

Jimmy
  • 275
  • 2
  • 6
  • 27