I’m working on a PowerShell-based Azure Function that processes webhooks from an e-commerce platform after customers complete their orders. During local development, everything worked perfectly when I tested with sample JSON data using tools like Postman.
Here’s the sample JSON structure I was working with:
{
"order_id": 945612387451230000,
"customer_email": "[email protected]",
"status": "completed",
"order_date": "2021-03-15T14:22:18+00:00",
"last_modified": "2021-03-15T14:22:18+00:00",
"order_number": 567,
"notes": null
}
Locally, I could parse this data easily:
$ParsedData = $Request.Body | ConvertFrom-JSON
$CustomerEmail = $ParsedData.customer_email
However, when the actual webhook hits my deployed function, the JSON conversion fails with this error:
WARNING: Conversion from JSON failed with error: Unexpected character encountered while parsing value: S. Path '', line 0, position 0.
When I output the raw request body, I see:
INFORMATION: System.Collections.DictionaryEntry System.Collections.DictionaryEntry System.Collections.DictionaryEntry
It seems like the webhook data is already parsed into a dictionary object rather than being received as a raw JSON string. My function starts like this:
param($Request, $TriggerMetadata)
try {
$ErrorActionPreference = "Stop"
Connect-AzAccount -Identity
Write-host $Request.Body
What am I missing here? Why does the live webhook behave differently than my local testing setup?