Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Request Accept header '*;q=.2' is not a valid media type

Hi,

 

I am getting the error below while using OAS Validation policy.

 

Header in Request which is causing the issue:

Accept text/html,image/gif,image/jpeg,*;q=.2,*/*;q=.2

 

Error:

OASValidation OpenAPI-Spec-Validation with resource \"oas://Sample.yaml\": failed with reason: \"[ERROR - Request Accept header '*;q=.2' is not a valid media type: []]\"",
 
Tried using the below configuration to bypass this error, but this doesn't help.
 
I understand that the 'Accept' header can be modified to resolve this. However wanted to understand if there are any other ways to solve this !!
 
<OASValidation continueOnError="false" enabled="true" name="OpenAPI-Spec-Validation">
<DisplayName>OpenAPI Spec Validation</DisplayName>
<Properties/>
<Source>request</Source>
<Options>
<AllowUnspecifiedParameters>
<Header>true</Header>
</AllowUnspecifiedParameters>
<ValidateMessageBody>true</ValidateMessageBody>
</Options>
<OASResource>oas://Sample.yaml</OASResource>
</OASValidation>
 
Thanks
0 2 3,394
2 REPLIES 2

If I understand correctly, it looks like a bug to me.  I suggest that you contact Apigee support, they can raise a bug on your behalf. 

It is about 4 months after the question, but maybe this could help someone else.

Also, this is not a solution, but a workaround.

You can set in OASValidation the property continueOnError as "true" and add a RaiseFault component after this with condition:
Not (OASValidation.OpenAPI-Spec-Validation.fault.cause JavaRegex ".*Request Accept header '\*; q=\.2' is not a valid media type.*")

(the regex is very specific, but OASValidation always throws the error the same way, so it is pretty safe I believe)