Executing a local service bus queue trigger gives "Unexpected status code: 400" error with JSON request body
Issue
Passing in valid JSON into the request body of a service bus queue trigger results in a "Unexpected status code: 400" error, and the function does not execute.
Any valid JSON seems to cause this error; I tried passing in a JSON service bus message with the payload in body as a string and object but received the same error.
Expected Behavior
When valid a valid JSON payload is entered in the service bus message payload prompt, the payload should be passed as a deserialized object to the service bus message trigger function argument. This is what appears to happen when the deployed function is triggered regardless of ContentType.
Steps to Reproduce
- Create function
- Select "Azure Service Bus Queue trigger"
- Select defaults for remaining prompts
- Run
func start - Execute function
- Select created function
- Enter valid JSON in request body prompt
- Receive error
Context
- Windows 10 OS
- TypeScript Function Project Runtime
- VSCode v1.62.2
- Azure Functions Extension v1.6.0
- Azure Functions Core Tools v3.0.3904
- Function Runtime v3.3.1.0
Same here, I can pass in a simple string and it will work but not with json. Possibly after updating VS Code to 1.62.3
Downgrading Azure Functions Extension to 1.6.0 and 1.5.2 does not help the issue.
Ok I figured how to get past this. I wrap the payload in a single quote and then everything works, maybe it has always behaved like that... :)
Wrapping the payload in a single quote does not exactly fix my issue.
It does execute the trigger, but the service bus message argument is now a JSON string wrapped with single quotes.
I'd expect the extension to mimic the behavior of a triggered deployed function and pass an already-parsed object to my trigger.
I will update my original issue with expected behavior.
I am encountering the same issue with Python Azure Function attempting to run locally. The JSON blob cannot be accepted as a request body.
Having same issue now. Approach with quote does not work, because payload becomes string and this is obviously not what we expect (js object). Please look at this urgently, without this fix the whole extension is mostly useless IMO.
Has anyone found a workaround for this? Open issue for nearly a year, just bumped into it while experimenting with an Event Grid Trigger. Same behavior as initially reported where a request will encounter a status 400 and the function isn't triggered. As noted above, surrounding the JSON body with single quotes the function is triggered but unable to be parsed. Through the Azure portal, the exact same body works as expected.