cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Syndicate_Admin
Administrator
Administrator

Custom Connector - How to get the JSON from the user and place it in the body of the request?

Hello,

 

I am building a custom connector for an application. One of the POST endpoint requires a JSON body as

 

{
"itemData": {
"Name": "string",
"Priority": "High",
"SpecificContent": {
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
},
"DeferDate": "2021-07-28T13:07:46.546Z",
"DueDate": "2021-07-28T13:07:46.546Z",
"RiskSlaDate": "2021-07-28T13:07:46.546Z",
"Reference": "string",
"Progress": "string"
}
}

 

When i import from a sample, All parameters are recognized and added to the parameters except SpecificContent which is a JSON object and dynamic. How do i make this as one of the input field to accept JSON from the user?

 

Thanks

4 REPLIES 4
cchannon
Solution Sage
Solution Sage

Specific Content would not be one prop, but rather additionalProp1, 2, and 3 would each be an input prop.

 

Paste in your full example json (with values for these props, not empty json objects) into the Body box when defining your action and the custom connector will automatically do this.

 

Walkthrough that shows an example Body definition here.

Thanks for your reply!

 

Currently it getting handled in that way. Additional prop 1, 2 and 3 are getting defined as input from the sample. But my JSON for specific content is dynamic. The properties in specific content will vary in each case. So, looking for an option to accept the specific content object from user

 

Ex:

{
"itemData": {
"Name": "string",
"Priority": "High",
"SpecificContent": {
"additionalProp3": "Test"
},
"DeferDate": "2021-07-28T13:07:46.546Z",
"DueDate": "2021-07-28T13:07:46.546Z",
"RiskSlaDate": "2021-07-28T13:07:46.546Z",
"Reference": "string",
"Progress": "string"
}
}

 

Example 2:

{
"itemData": {
"Name": "string",
"Priority": "High",
"SpecificContent": {
"Name": "Dinesh",
"City": "London"
},
"DeferDate": "2021-07-28T13:07:46.546Z",
"DueDate": "2021-07-28T13:07:46.546Z",
"RiskSlaDate": "2021-07-28T13:07:46.546Z",
"Reference": "string",
"Progress": "string"
}
}

OK, I get you. I don't think custom connectors have a 'JSON' input type within a Body definition (just string, bool, number AFAIK), so you will have to get creative. Your JSON object is dynamic, ok, but is there a full range of values that might be there? You could just write a sample body that includes every possible SpecificContent prop.

 

The other option is to experiment with the string types to see if you can trick it into accepting a string without adding quotes. If you dig into your body obj (edit) and then to your SpecificContent obj (edit) you will see that you can only define an input as String, Bool, Number...

cchannon_0-1627567037665.png

But you will also see a few string Types (byte, binary, date...):

cchannon_1-1627567073394.png

I have never tried this, but it is possible that one of these string types won't wrap in quotes. I would try each of these and see if one of them can trick it into accepting your JSON as string.  Worth a try, at least.

So, TIL that you CAN give raw JSON as an input to custom connector types, you just need to click the little "switch to input button in the upper right of your action definition:

cchannon_1-1627735890206.png

That little guy, circled in red above switches your input to this:

cchannon_0-1627735853431.png

That oughta let you do EXACTLY what you're looking for. Have fun!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,065)