-
Hey, guys! I've been trying to run an artisan command through the AWS CLI, but it doesn't work at all.
The php-82 and console layer seem to be set correctly. I get the error: An error occurred (InvalidRequestContentException) when calling the Invoke operation: Could not parse request body into json: Could not parse payload into json: Unrecognized token 'route': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') But if I execute the following command: This is my answer: It seems that artisan/Lambda is configured correctly, but maybe the artisan command syntax needs to be adjusted.. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi,
That tells me that the payload sent to Lambda is not recognized as a JSON string. I.e. Maybe some quotes need to be escaped with backslashes or something like this. I'm surprised that this works differently than |
Beta Was this translation helpful? Give feedback.
-
Hey! Thanks for the answer!
Yeah, that's what I've been thinking about and I actually tried everything that came up to mind and still get those errors :( Do you have any suggestions on how should I try to execute the artisan commands? |
Beta Was this translation helpful? Give feedback.
Hey, man! Thanks one more time!
I finally could solve it!
Actually, the cli key is necessary indeed but it also needs to be escaped with backslashes like you mentioned previously.
This is it how worked for me:
aws lambda invoke --function-name functionName --cli-binary-format raw-in-base64-out --payload '{ \"cli\":\"route:list\"}' out
The bref documentation says:(https://bref.sh/docs/runtimes/console)
Note: The --payload needs to contain a JSON string, that is why it is quoted twice: '"..."'. This is intentional.
So maybe the command itself doesn't need to be quoted twice anymore I suppose? I'm not sure..
Anyway, thanks for the help!