Skip to main content
Post a question

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Custom Connector odd behavior

Like (1) ShareShare
ReportReport
Posted on 6 Jan 2024 18:51:37 by 7
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
 
 
Thanks
 
Ben
  • Verified answer
    Community member Profile Picture
    Community member 7 on 06 Jan 2024 at 20:32:04
    Custom Connector odd behavior
    I was able to work around the issue by matching the JSON expected by the Custom Connector by adding the additional elements in Power Automate
     
    {
      "body": {
        "$": @{outputs('GetRows')?['body']}
      }
    }
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,759 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans
Loading started