API Manager Profile - Error 406

Try to create a new API profile in Matillion, but keep getting error 406. When I tried using curl command it's working fine.

 

Below from Matillion API GUI:

 

Request header parameters:

X-Api-Key: ********

 

Request query parameters:

from: 2021-09-20

until: 2021-09-27

 

Status code received: 406

 

Response headers: 

Keep-Alive: timeout=10

Transfer-Encoding: chunked

Server: nginx

Access-Control-Allow-Methods: GET, POST, DELETE, PATCH, OPTIONS

Access-Control-Allow-Credentials: true

Connection: keep-alive

Access-Control-Allow-Headers: DNT,Authorization,X-Role-Id,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type

Date: Mon, 11 Oct 2021 04:27:40 GMT

Content-Type: application/problem+json

 

[Error]: {"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html","title":"Not Acceptable","status":406,"detail":"Unable to resolve Accept header to a representation"}

Hi @i.setiawan​,

It looks like the 406 is being generated because your Accept header doesn't align with what the API is returning. As an example, if you or the API Profile sets the Accept header with a value of "application/json" meaning you are expecting to get back JSON but then the API returns "application/xml" then you will have this 406 failure. The key is to make sure your Accept value aligns with with the API method is returning. When you setup the API Query component you can set up custom headers. You do this by going to the Connection Options ellipses in the API Query component and choosing CustomHeaders for the parameter. For the value I believe you want to it to be Accept: application/json or Accept=application/json where application/json is whatever format matches the return of the API method.

I hope this helps!

Bryan

On Configure Query Profile, select your rsd, then turn on Advanced Mode and manually add the Accept header:

 

<api:script method="GET">

  <api:set attr="method" value="GET"/> 

  <api:set attr="Accept" value="*/*"/> 

  <!-- HTTP request type -->

  <api:call op="jsonproviderGet">

   <api:push/>

  </api:call>

 </api:script>

I tried as your recommendation by putting customheader in connection option, but still getting the 406 error. I also have submitted/raised ticket to support team to help on this.

Another suggestion that might give you more visibility would be to set Auto Debug On and the Debug Level to 3 on the API Query component. This should give you a bit more information about the request and response. It should also give you an idea of what headers are past in the request.