Open Prajwalgn-07 opened 7 months ago
And yeah I tried setting the body value to string instead of the json input, and set the header
"headers": {
"Authorization": "Bearer <Removed Token>",
"Content-Type": "application/json"
}
Then I am getting the HttpMediaTypeNotSupportedException which doesn't make sense
START RequestId: 1f2fab44-1d58-47a9-bad9-d9718ef5b497 Version: 3
2024-04-21T12:44:04.309Z WARN 8 --- [fusion-ai-service] [ main] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content-Type 'application/octet-stream' is not supported]
2024-04-21T12:44:04.309Z INFO 8 --- [fusion-ai-service] [ main] c.a.s.p.internal.LambdaContainerHandler : 127.0.0.1 null- null [09/04/2015:12:34:56Z] "POST /api/v1/inference HTTP/1.1" 415 - "-" "Custom User Agent String" combined
END RequestId: 1f2fab44-1d58-47a9-bad9-d9718ef5b497
REPORT RequestId: 1f2fab44-1d58-47a9-bad9-d9718ef5b497 Duration: 3.40 ms Billed Duration: 4 ms Memory Size: 512 MB Max Memory Used: 154 MB
And yeah I tested by locally bringing up the service using sam and . there it seems to be working fine
Thanks for raising this. We will look into it.
Hey @Prajwalgn-07,
I have tried to reproduce your issue and figure out the cause. In this case I think the issue is with your JSON file, and you were almost on the right path. You need to keep your body
value to String instead of json. And you have to set content-type
in multiValueHeaders
instead of headers
, something like mentioned below will work.
"multiValueHeaders":{
"content-type":["application/json"]
},
Please set this and let us know if you still get errors.
To help us debug your issue fill in the basic information below using the options provided
Serverless Java Container version:
2.0.1
Implementations:
Spring Boot
Framework version:
SpringBoot 3.2.4
Frontend service:
REST API
Deployment method:
Serverless Framework
Scenario
Describe what you are trying to accomplish
Hello I am creating a lambda function for my service. when I try to call my post API with the json body from lambda test console it is not able to deserialize it into the object which is defined in my code
Expected behavior
Describe how you would expect the application to behave When I pass the body as json input it should get deserialized and consumed in my spring boot application
Actual behavior
Describe what you are seeing instead It is throwing
java.lang.String
from Object valueSteps to reproduce
*Provide code samples we can use to reproduce the issue as part of our integration tests. If there is a public repository for the misbehaving application link to it here
Below is the test input given
StreamLambdaHandler
Rest Mapping
Full log output
Paste the full log output from the Lambda function's CloudWatch logs
Below is the stack trace