Abdurahman Hijazi
08/24/2022, 1:56 PMmockProvider.addInteraction({
state: "",
uponReceiving: `An invalid POST request to ${Config.config.SSO_TOKEN_PATH}. Returns 400 status and "invalid_grant_type" message`,
withRequest: {
method: "POST",
path: "/v1/api/token",
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
},
body: createFormBody(request),
},
willRespondWith: {
status: 400,
body: {
error: "unsupported_grant_type",
error_description:
"Invalid grant type INCORRECT_GRANT_TYPE, expected authorization_code",
error_uri: null,
},
},
});
But for some reason, when the pact is generated, a header is added in the interaction in the API response
{
"description": "An invalid POST request to /v1/api/token. Returns 400 status and \"invalid_grant_type\" message",
"request": {
"body": "grant_type=INCORRECT_GRANT_TYPE&client_id=34343433434&redirect_uri=REDIRECT_URL&code=AUTH_CODE&code_verifier=VERIFIER",
"headers": {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
"method": "POST",
"path": "/v1/api/token"
},
"response": {
"body": {
"error": "unsupported_grant_type",
"error_description": "Invalid grant type INCORRECT_GRANT_TYPE, expected authorization_code",
"error_uri": null
},
"headers": {
"Content-Type": "application/json"
},
"status": 400
}
}
Any ideas on how to stop this from happeningTimothy Jones
08/24/2022, 10:16 PMA sender that generates a message containing a payload body SHOULD generate a Content-Type header field in that message unless the intended media type of the enclosed representation is unknown to the sender
Timothy Jones
08/24/2022, 10:17 PMI stated that the Mock API doesn’t return any headers in its response.You’ve stated that your client doesn’t care about the headers, not that the response has no headers.
Timothy Jones
08/24/2022, 10:18 PMTimothy Jones
08/24/2022, 10:20 PMapplication/json. Is there some reason you need it not to be?