cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Microsoft
Microsoft

Convert object in request to string

I have a post api which takes input or request body as such:

{

"TempName":"123",

"TempInput":"{

  "User1":"mark",

  "User2":"trevor"

}"

}

The "user1" and "user2" are dynamic and I first fetch the schema using TempName(I do it using x-ms-dynamic-schema in th swagger and it works fine,IN FLOW it shows me two text boxes with labels "user1" and "user2" dynamically and i can enter mark and trevor in it;for some other TempName it could show different number of text boxes). Now, my request body becomes like:

{

"TempName":"123",

"TempInput":{

"user1":"mark",

"user2":"trevor"

}

}

I totally oversaw the two double quotes for TempInput's value actually required(that means it is taking a string and not object) and there is no option for me to create a string dynamically in my connector. So, is there a quick fix to convert the object to string and send it as TempInput?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Convert object in request to string

ohh @t-prrath  I understhand, and my advide is change your API, to accept json, because everyting you manage here in PA is using Json languaje so change your API to accept objects is the best way. 😉



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

Re: Convert object in request to string

hi @t-prrath  If I  understand well this is what you need, imagine that my output has your json result.

 

string.PNG

string(outputs('Compose'))


Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Microsoft
Microsoft

Re: Convert object in request to string

Hey @ChristianAbata thanks for the reply but let me clarify; I'll put an image here:

Z.png

If you observe, this is my action in my custom connector: If i enter GDPR it shows me 5 boxes(dynamically): if i fill those and run the flow, the connector sends the request as 

{

 "TempName":"GDPR",

 "TempInput":{

   "GDPR_Name":"mark",

   "GDPR_PostalAddress":"utopia",

   "GDPR_EmailAddress":"something@something.com",

"GDPR_PhoneNumber":"0",

"GDPR_ActionType":"do something"

  }

}

but the POST API actually expects that the TempInput be a string and not a JSON object; now I cant compromise on the UI; because I want my end user to fill his stuff in my connector's text boxes rather than fillin JSON in compose operation. So how do i workaround this? Do i change my api to accept JSON object or can  I use something I am missing IN THE FLOW itself ?

Highlighted
Super User III
Super User III

Re: Convert object in request to string

ohh @t-prrath  I understhand, and my advide is change your API, to accept json, because everyting you manage here in PA is using Json languaje so change your API to accept objects is the best way. 😉



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (6,946)