I've built a Custom Connector to parse a complex and large JSON payload. This custom connector accepts a JSON body and returns a JSON response.
I then built the Power Automate flow to get the JSON output from a Dataverse Query. The output that I am interested in is sent to the Custom Connector as outputs('DataFromDataverse')?['body']. So far so good.
PowerAutomate Code View snippet
PowerAutomate Code View snippet{ type: OpenApiConnection, inputs: { parameters: { content-type: application/json, body: @outputs('DataFromDataverse')?['body'] },
I then executed the flow once, sourced the JSON and proceeded to use the JSON to continue the C# code within the Custom Connector. The JSON generated by the above steps looks like so...
{ @odata.context: , value: [ { @odata.type: #Microsoft.Dynamics.CRM.contact, ...... }}
The value section has the Array that contains data from the expanded table. The issue is not with this Query or the format, this is a standard response.
When I use this JSON schema to complete the C# development and use the JSON as an Example to test out the Connector, the Custom Connector JSON Body has it's own syntax, which looks like below. I renamed the default /body/ to /raw/, since a body with another body was confusing.
{ raw: {body:{$:{ @odata.type: #Microsoft.Dynamics.CRM.contact: .....}
the actual JSON payload from Power Automate would in this case be treated as a String. I am able to consume the value of the /raw/ (or body) key and parse into JSON.
The issue is not with parsing the JSON. The issue stems from the fact that the Custom Connector Test pane seems to enclose the actual JSON with a /body/ node and then also adds the /$/ node. This schema does not match with the schema that Power Automate uses. There seems to be an underlying behavior difference between developing this and consuming it.
Kindly let me know if I am doing something wrong. How I keep the JSON input between Power Automate <> Custom Connector and the Custom Connector Test tab consistent