We have a legacy API that is a POST method. In the body of the post, we have the following:
{
"headerParam": {
"user_Key": "our-in-house-user-key-goes-here",
"license_key": "our-in-house-license-key-goes-here"
},
"Transactions": null,
"SalesDateTime": null,
"state": "Washington",
"methodName": "GetInventoryTransfer",
"methodType": "GET",
"global_id": "WALLAB.ITJZ4"
}
This particular service is calling another 3rd party service - it is calling their "GET" on the method "GetInventoryTransfer". Our wrapper API is a POST (not sure if any of that matters).
We are trying to use this API in PowerApps.
Our flow looks like this:
Flow
FLow showing POST body and Response body
The formula we use for the OnSelect for the PowerApp button that triggers this flow is:
ClearCollect(colResponse, GetInventoryItemByGlobalId.Run())
All the collection is getting back is the value "true". We I replace the collection with a regular variable such as:
Set(varResponse, GetInventoryItemByGlobalId.Run())
the value of varResponse is "true".
When I run the flow inside of the flow environment, I get the following output:
The flow runs as expected and the body in the Outputs is the data I am trying to receive in my PowerApps app.
Any suggestions?
@v-bacao-msft wrote:Hi @tbelvin ,
You could consider using Parse JSON action.
Configure the Response Body JSON Schema in the Parse JSON Schema and configure the Response output body in the Content.
This way Dynamic Content generated by Parse JSON seems to be what you need.
Best Regards,
I have sucessfully achieved something similar using the technique Barry hase decribed, albeit without the Parse JSON (Data Operations) action but instead using the Select (Data Operations) action.
I went into "somewhat" more detail in a blog I subsequently posted which may well be aligned with your specific requirements:
Leveraging Graph APIs in PowerApps & Flow – Photos
Of most relevance in the blog insofar as the steps Barry highlighted are the final 3 steps in my own flow:
The "Get items v2" is the equivalent of your HTTP wrapper API step, albeit that in my Flow that step is a GET request performed against a SharePoint HTTP REST API and not a POST. The could well be of relevance. Of equal relevance, I also include a Header in the request to return the output as JSON:
At this point you would need to run the Flow (within the Flow environment) in order to then subsequently generate a sample set of data (JSON) from the output of the HTTP request.
For my own Flow the Body output ("JSON") from own SharePoint HTTP REST APP call was in essense too complex to use as a sample payload required for the Parse JSON action.
Whilst I don't profess to be an expert insofar as having worked with this I type of development, I nonetheless supspect if the JSON returned for my own HTTP request had been less complex, inserting a Parse JSON action prior to the Select action may well have made it far easier to subsequently select the fields from Dynamic content variables generated / exposed from a Parse JSON step, to use as input into the Select action.
If so, the Parse JSON step would look as follows:
You would then click the Use sample payload to generate schema link and paste the JSON output from the pervious HTTP request step, following which the schema would be automatically generated.
That said, as noted, for my scenerio at least the sample JSON output generated from my own SharePoint HTTP REST API request was simply too complex for the Parse JSON action to automatically generate a valid schema. Consequently I used one of the many JSON formatters on the web such as this one, such that the JSON was thereafter transformed into something at least readable in order than I could then manually construct/code the fields I wanted to return to SharePoint as an array leveraging the Select data operations action, which then looked as follows:
Breaking this down further,
For the *From property, the exact code was:
array(body('Get_items_v2')['value'])
For the *Map property Name property, the corrosponding code was:
@item()['name']
For the *Map property ContentType property (this being a complex type field), the corrosponding code was:
@item()['listItem']['contentType']['name']
etc...
Having now generated an array that PowerApps can understand, the final step in the Flow is to add as Response action in order to return the Output from the Select action in the Body property. However before you can add the Response action to the Flow, you once again need to provide a sample payload to generate the schema for the Response action by testing the Flow in the Flow environment, and copying the Body output of the Select action step to use as the sample payload to generate the schema:
Perhaps the most obvious difference between the content returned to PowerApps using this technique when compared to the screenshots you initially shared at least is that with this technique you can see that the schema for the Response actions returns the data to PowerApps as an array, whereas the Response schema per your initial attempt returned the data as an object.
That sounds like a reasonable solution but I can't figure out how to code the Flow step. I am not able to find any examples of it either.
Hi @tbelvin ,
You could consider using Parse JSON action.
Configure the Response Body JSON Schema in the Parse JSON Schema and configure the Response output body in the Content.
This way Dynamic Content generated by Parse JSON seems to be what you need.
Best Regards,
WarrenBelz
146,594
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,928
Most Valuable Professional