0
Möchten Sie verstehen, wie API API Gatway Post (Ereignis ['Körper'] ['Param']) an meine C# Lambda Funcion übergeben?C# AWS API Gatway Beitrag Params
ich habe:
public string FunctionHandler(Stream request, ILambdaContext context)
{ StreamReader reader = new StreamReader(request);
return reader.ReadToEnd();
}
aber mit Postbote (Beitrag Key Wert: "Hallo: world") kehrt:
'\"body-json\" : \"LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTcwMTQxNDY5ODUyNjQwNzI2NDM3ODU2OQ0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJUaGlzS2V5CiINCg0KV2hhdA0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTcwMTQxNDY5ODUyNjQwNzI2NDM3ODU2OS0tDQo='
(Keine Ahnung, was das darstellen soll)
Wenn ich tun:
public string FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context)
{ return "request body is:" + request?.Body; }
I Get "Anfrage Körper ist:"
Es ist ein leerer Körper?
Wo sind die Post-Werte?
Dies geschieht mit Hilfe formDaten und das Body-Mapping ist:
"## See http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
## This template will pass through all parameters including path, querystring, header, stage variables, and context through to the integration endpoint via the body/payload
#set($allParams = $input.params())
{
"body-json" : $input.json('$'),
"params" : {
#foreach($type in $allParams.keySet())
#set($params = $allParams.get($type))
"$type" : {
#foreach($paramName in $params.keySet())
"$paramName" : "$util.escapeJavaScript($params.get($paramName))"
#if($foreach.hasNext),#end
#end
}
#if($foreach.hasNext),#end
#end
},
"stage-variables" : {
#foreach($key in $stageVariables.keySet())
"$key" : "$util.escapeJavaScript($stageVariables.get($key))"
#if($foreach.hasNext),#end
#end
},
"context" : {
"account-id" : "$context.identity.accountId",
"api-id" : "$context.apiId",
"api-key" : "$context.identity.apiKey",
"authorizer-principal-id" : "$context.authorizer.principalId",
"caller" : "$context.identity.caller",
"cognito-authentication-provider" : "$context.identity.cognitoAuthenticationProvider",
"cognito-authentication-type" : "$context.identity.cognitoAuthenticationType",
"cognito-identity-id" : "$context.identity.cognitoIdentityId",
"cognito-identity-pool-id" : "$context.identity.cognitoIdentityPoolId",
"http-method" : "$context.httpMethod",
"stage" : "$context.stage",
"source-ip" : "$context.identity.sourceIp",
"user" : "$context.identity.user",
"user-agent" : "$context.identity.userAgent",
"user-arn" : "$context.identity.userArn",
"request-id" : "$context.requestId",
"resource-id" : "$context.resourceId",
"resource-path" : "$context.resourcePath"
}
}
Nein, gibt mir immer noch das Kauderwelsch für den Körper: \ "body \": \ "\\\" LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTY2OTI2MzM4NDA3NzA5NDM1NzMzOTQ5Mg0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJIZWxsb3dvcmxkIg0KDQpXaGF0DQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tNjY5MjYzMzg0MDc3MDk0MzU3MzM5NDkyLS0NCg = = –
Haben Sie den Inhaltstyp "application/json" verwendet? –
Nein, ich denke, ich war nicht so klar, aber ich benutze multipart/form-data als Inhaltstyp, weil ich binäre Informationen (ein Bild) senden muss. Ich habe die binäre Unterstützung so eingerichtet, dass sie auch multipart/form-data basierend auf dieser Lektion verwendet: [link] (https://aws.amazon.com/blogs/compute/binary-support-for-api-integrations- with-amazon-api-gateway /) –