cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RobertPearman
New Member

Custom API - Body is Not Valid JSON

I have a custom API in Azure, which accepts JSON object as the body of the request.

 

A custom connector in PowerAutomate insists the body of a request must be in JSON format.

 

In a flow i have a string which i would like to send to the API. Without using a compose action to put that string inside a JSON object manually, how can i tell the connector/parameter that whatver goes in there should be sent as a JSON object.

 

For example, if you look at the connector for Encodian, you can specify a regex and any dynamic content. I assume in the background the dynamic content is reformatted as a JSON and then sent to encodian.

1 ACCEPTED SOLUTION

Accepted Solutions
RobertPearman
New Member

I have figured this out!

 

Firstly, i was making this much more difficult than it needs to be, so this is really a case of user error, but i will put in the solution i have come up with.

 

In the box highlighted below - enter your JSON format/schema. Whatever you put here will be available in your connector inside the flow/app as options.

 

RobertPearman_0-1618746093297.png

For example, if i enter an object with simple json as a name,

RobertPearman_1-1618746268271.png

Then in my flow i have the option to use dynamic content/expression in the JSON field, then the query is part of the HTTP request. 

 

RobertPearman_2-1618746410932.png

When sent to the API, the JSON object is now..

{

"json" : triggerOutputs()?['body/body']

}

 

Then just add in your response schema as usual when creating any custom connector, and the outputs are available for subsequent actions as dynamic content.

View solution in original post

2 REPLIES 2
RobertPearman
New Member

I have figured this out!

 

Firstly, i was making this much more difficult than it needs to be, so this is really a case of user error, but i will put in the solution i have come up with.

 

In the box highlighted below - enter your JSON format/schema. Whatever you put here will be available in your connector inside the flow/app as options.

 

RobertPearman_0-1618746093297.png

For example, if i enter an object with simple json as a name,

RobertPearman_1-1618746268271.png

Then in my flow i have the option to use dynamic content/expression in the JSON field, then the query is part of the HTTP request. 

 

RobertPearman_2-1618746410932.png

When sent to the API, the JSON object is now..

{

"json" : triggerOutputs()?['body/body']

}

 

Then just add in your response schema as usual when creating any custom connector, and the outputs are available for subsequent actions as dynamic content.

View solution in original post

v-litu-msft
Community Support
Community Support

Hi @RobertPearman,

 

I am glad your issue has been solved by yourself.

You could go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

Best Regards,
Community Support Team _ Lin Tu

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (26,667)