UPDATE: I just noticed in the CloudWatch logs, that the content type has somehow mutated from application/json to text/plain. Here is what the WebHost string looks like now:
[Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request starting POST https://snip.execute-api.us-west-2.amazonaws.com/Stage/api/Clinician text/plain
This is what it looked like when the call was working:
[Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request starting POST https://snip.execute-api.us-west-2.amazonaws.com/Stage/api/Clinician application/json And yet, the header in Postman sets Content-Type: application/json
So why is the content type changing?
Beginning of original post:
I'm developing an API Gateway Lambda Function using Visual Studio 2017 "Serverless Application with Test" blueprint which is a .NET CORE solution. We are using Cognito User Pools for authentication. I am using Postman to test my first function. I'm passing a valid ID Token for a User in a Cognito User Pool. The request passes authentication but responds with a 415 Unsupported Media Type.
Before I started passing an ID Token, I was using AWS_IAM authorizer. At that time, the body (content-type: application/json) would map to the POST parameter successfully. But now that I am using the Cognito User Pool authorizer, I get a 415 Unsupported Media Type when calling POST. The POST method signature is:
[HttpPost]
public APIGatewayProxyResponse Post([FromBody]Clinician user)
The sample data I am sending in the body is:
{
"Id": "",
"Username": "6punk",
"Title": "Punker",
"FirstName": "Six",
"MIddleName": "",
"LastName": "Punk",
"Suffix": "",
"PreferredFirstName": "",
"PreferredLastName": "",
"Email": "[email protected]",
"Phone": "+18015551206",
"UserSub": "",
"ClinicianTypeId": "1",
"EhrId": ""
}
As already mentioned, when authenticating as an IAM user or when testing via the Method Test pane in the API Gateway Console, the JSON maps perfectly to the Clinician class.
I have CORS enabled. For the ANY method, I have the Integration Request type set to LAMBDA_PROXY.
Any ideas what is causing the 415 Unsupported Media Type when testing my POST method from Postman with an ID Token from a Cognito User?
cURLcode that Postman generates when you send that request?