-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lambda.Invoke failing with payload; "Could not parse request body into json" #1876
Comments
For future reference, I was able to do:
However, I still contend that this means the docs are wrong, because they suggest you can send a string. Technically that's correct, but the string must be JSON. |
Hi @brettneese, Unfortunately, the generated example code example referred to only knows about the data types required for each property of an operation's input and output; it is not aware of any semantic restrictions on what data those properties may contain. Each property is documented below the example, however, which is where more thorough information about properties is communicated. The |
Hey @jeskew, yeah, that makes sense. I read this thing many times and did not see that, and it seems there are a few others on the internets with this problem without a solution as well (hopefully they will Google and find this answer). The message coming back from Lambda is also less than helpful here, so that might be a good solution. Thanks for your response! |
I have same bug
//////MY CODE |
I GOT IT!
|
Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue. |
aws lambda invoke --function-name demo-func-async --invocation-type Event --payload $(echo '{ "name": "crearerd" }' | base64) response.json encoding the payload to base64 works for me |
Hello guys, I am also trying to do something similar...and facing error. |
I've just blown the last 3 hours because I couldn't get the payload to make it into the lambda, and following Amazon's example exactly, did not work. Where does it say that it has to be base64 encoded? Once I tried to do this using Invoke (payload) in C#, the client immediately complained it could not encode JSON.. So I just created a request object and serialized it directly into the payload variable, and it finally worked. Hope this helps someone. Edit: I had tried to create the string manually and it wasn't having it, the member variable in the object came through as null, no errors. |
Yeah explicitly in the CLI docs here: https://docs.aws.amazon.com/cli/latest/reference/lambda/invoke.html#examples
Yet if I do the same thing I get a "Could not parse request body into json" from the cli. |
Possible solution: |
@JacobWeyer - you'll need to add the following flag, aws lambda invoke \
--function-name my-function \
--payload '{ "name": "Bob" }' \
--cli-binary-format raw-in-base64-out \
response.json
# or from a file, you can use `fileb`
aws lambda invoke \
--function-name my-function \
--payload fileb://payload.json \
response.son |
Using 2.180.0, running simply:
as per the SDK docs returns:
"{ InvalidRequestContentException: Could not parse request body into json: Unrecognized token 'STRING_VALUE': was expecting ('true', 'false' or 'null')}"
This seems to be a response from the Lambda server, so either the docs are wrong or Lambda is broken. I don't know where else to submit this bug, since AWS support is impossible to get a hold of in a timely fashion without paying AWS lots of money.
Setting the
Payload
tonew Buffer('hello world')
also fails.Running it without a
Payload
is fine, although rather useless. I should have more than adequate permissions on my local machine to execute the function.The full stack trace:
The text was updated successfully, but these errors were encountered: