I was working my way through the Azure Quickstart, and I noticed that the command serverless invoke -f hello -d '{"name": "Azure"}'
returns this error: “The specified input data isn’t a valid JSON string.” Does anybody know why this happens? Here is my serverless version:
Framework Core: 3.22.0 (standalone)
Plugin: 6.2.2
SDK: 4.3.2
Here is the function code:
'use strict';
module.exports.sayHello = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
if (req.query.name || (req.body && req.body.name)) {
context.res = {
// status: 200, /* Defaults to 200 */
body: 'Hello ' + (req.query.name || req.body.name),
};
} else {
context.res = {
status: 400,
body: 'Please pass a name on the query string or in the request body',
};
}
};