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

PowerApps JSON Request

I am trying to build a proof of concept where a field in a PowerApp is validated against a custom api held in an Azure Function. I have created the swagger file for the function which for demo purposes just uses the following JSON as the body in a POST request, and returns a text value back

 

{

   Text1:string,

   Text2:string,

   Text3:string

}

 

I have been able to create a custom connector and when used in MS Flow I get presented with the 3 text boxes and it all works fine. My problem comes when calling the same custom connector from PowerApps, since I cannot see how to build a JSON body. Just to prove the concept I am trying to set Text1 to "Text 1", Text2 to "Text 2" and Text3 to "Text 3"

 

I have tried many variations of the following, where I try and set a variable to the return value and sometimes use char(34) to try and force " into the string, but the body always seems to have the complete string inserted into the Text1 JSON element, and Text 2 and Text 3 are empty

 

Set(ValidationText,PoC.Validate("{" & Char(34) & "Text1" & Char(34) & ":" & Char(34) & "Text 1" & Char(34) & "," & Char(34) & "Text2" & Char(34) & ":" & Char(34) & "Text 2 Value" & Char(34) & "," & Char(34) & "Text3" & Char(34) & ":" & Char(34) & "Text 3 Value" & Char(34) & "}"))

 

So in this case when the request arrives at the function Text1 would end up as the string

{"Text1":"Text 1","Text2":"Text 2 Value","Text3":"Text 3 Value"}

and Text2 and Text 3 empty

 

So how can I construct a JSON body and pass it to ValidationText.POC.Validate, when PowerApps thinks there is just the one parameter required for the function?

1 ACCEPTED SOLUTION

Accepted Solutions

Not exactly an answer but a different perspective.

 

For me, Flow is so much better at this stuff. What I do with my apps is have PowerApps call Flow. Let Flow deal with the API stuff and then have Flow return to PowerApps just the values I needed. No more PowerApps JSON chaos. Might be worth considering.

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

View solution in original post

2 REPLIES 2

Not exactly an answer but a different perspective.

 

For me, Flow is so much better at this stuff. What I do with my apps is have PowerApps call Flow. Let Flow deal with the API stuff and then have Flow return to PowerApps just the values I needed. No more PowerApps JSON chaos. Might be worth considering.

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

AhI never thought of that option. Being new to PowerApps, I just assumed that it would handle api connections created  with swagger files the same way as Flow does, but my recent experince with PowerApps seems to contradict that. I will certainly give it a go, and report back if it solves the issue. Many thanks

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,294)