Ich versuche, die HTTP-Header und Textdetails in AWS Lambda-Funktion mit Java, die durch POST-Methode mit AWS API gesendet werden. Bisher habe ich die Verbindung zwischen AWS API und AWS Lambda Function erfolgreich eingerichtet und kann sie über das API Gateway aufrufen. Um nun Kopfzeilen an die Lambda-Funktion zu übergeben, habe ich alle Schritte vor "Aktualisierung der Lambda-Funktion" von here durchgeführt. Im Anschluss ist mein Lambda-Code:HTTP-Header von AWS-API an Lambda-Funktion übergeben
import com.amazonaws.Request;
import com.amazonaws.Response;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.S3Event;
public class SimpleSysout implements RequestHandler<Request, String> {
public String handleRequest(Request request, Context context) {
System.out.println("Method = "+request.getHttpMethod());
System.out.println("Headers= "+request.getHeaders().toString());
System.out.println("Content= "+request.getContent().toString());
System.out.println("Servcie Name = "+request.getServiceName().toString());
System.out.println("Resource Path = "+request.getResourcePath().toString());
return request.toString();
}
}
Aber ich bekomme Fehler wie
{
"errorMessage": "An error occurred during JSON parsing",
"errorType": "java.lang.RuntimeException",
"stackTrace": [],
"cause": {
"errorMessage": "com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.amazonaws.Request, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information\n at [Source: [email protected]; line: 1, column: 1]",
"errorType": "java.io.UncheckedIOException",
"stackTrace": [],
"cause": {
"errorMessage": "Can not construct instance of com.amazonaws.Request, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information\n at [Source: [email protected]; line: 1, column: 1]",
"errorType": "com.fasterxml.jackson.databind.JsonMappingException",
"stackTrace": [
"com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)",
"com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:889)",
"com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:139)",
"com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1511)",
"com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1102)"
]
}
}
}
habe ich auch versucht, verschiedene Parameter anstatt die Anfrage, wie Ereignisse mit, aber keiner von ihnen arbeiten.
Sie können Ihre Mapping-Vorlage veröffentlichen. –