Hi all,
I am trying to store an array of objects in JSON retrieved by using custom connector inside Power Apps. I want to store those values inside a global variable and use it as an Item or value inside different controls (galleries, labels, etc.).
I've applied custom connector operation to OnSelect property of a button:
UpdateContext({varProjectData: GetActiveProjects.getactiveproject({'access-token': "Bearer xxxxxxxxxxxxxxxx", email: "employeemail@testaddress.com"})})
The above formula: I have to provide token inside a header as well as the body parameter (email) in order to retrieve the data. The result should be stored in a variable "varProjectData". Below is the data I am getting as response when testing with Postman or Power Automate:
[
{
"project": "Client Name1: Project Name1 (project-code1)",
"projectmanageremailaddress": "manager1@testaddress.com"
},
{
"project": "Client Name2: Project Name2 (project-code2)",
"projectmanageremailaddress": "manager2@testaddress.com"
},
{
"project": "Client Name3: Project Name3 (project-code3)",
"projectmanageremailaddress": "manager3@testaddress.com"
}
]
Now, I've tried to work with this data inside Power Apps but whatever I try I get errors. In addition, I've found several tutorials and videos explaining how to parse JSON with ParseJSON function when it is in untyped object format, but the problem is that everyone explains how to parse it when the data is already pasted as text inside a label in Power Apps... In my case I have to retrieve the data while the app is in use, store it in a variable and then work with it in real time.
For example, inside the app a manager selects a user for which he wants to see on which projects that particular user is working. After clicking on a button, an API call should be triggered and the data should be retrieved and some labels should be populated with the data (project name and project manager).
I was successful in populating labels when the response was returned as JSON string, but when it is returned as an array of objects I'm having a difficult time figuring out the solution.
Hope someone has an idea how to solve this.
Thank you
Okay, that would be one way to approach it. I actually mispoke earlier about how to handle the case where the response was already a table. What to do is run ParseJSON() on each record in the table using the function ForAll().
while trying to recreate the issue I am facing, I eventually figured out the solution. While I couldn't use the variable for the Label, I could use it as the DataSource of the gallery which is the thing I needed in the first place. The problem here is that I started testings with the Label instead of going directly to the gallery and inserting the variable as the DataSource. We can consider this issue as solved.
Thank you for your replies and help.
You are correct with number 2. PA really does put the response in a table, but when I want to ParseJSON() on that table I am getting the following error:
FYI, var2 holds the response from custom connector and the below formula is defined for the OnVisible property of the screen:
UpdateContext({var2: GetActiveProjects.getactiveproject({'access-token': "Bearer xxxxxxxxxxxxxxxx", email: "employeemail@testaddress.com"})})
However, if the response is a pure string as it is the case with another custom connector (an API call to retrieve street address from an employee), I don't need to use ParseJSON(), but retrieve data from the variable in the following way. The variable is defined the same way as the above one:
UpdateContext({var1: GetStreetAddress.getstreetaddress({'access-token': "Bearer xxxxxxxxxxxxxxxx", email: "employeemail@testaddress.com"})})
Inside a text label I can get data simply by defining the Text property of the label:
var1.postcode
The link I mentioned in the first post (https://devoworx.net/powerapps-parse-json-examples/) works with ParseJSON() on a table, but the problem is that they already have data in JSON format inside the label. How did they get that data into a label is a mystery.
Hope I provided enough details to make things more clear.
Thank you
First a caveat, I have never used a custom connector, so I'm not certain how Power Apps is interpreting your response. I can only really think of a few situations: 1) the response is just a JSON string; ParseJSON() should work, so probably not the case here 2) Power Apps already puts the response into a table for you so you need to run ParseJSON() on the table. 3) Power Apps does something else related to parsing the response for you.
What do you see if you assign the response to a variable and then view the variable inside Power Apps?
Hi @Scott_Parker,
thank you for the reply. What I meant by that is that I was able to store/display the JSON value in Power Apps if JSON was in format like this:
{
"email": "my_address@mail.com",
"previous_yr_pto": "0",
"current_yr_pto": "21"
}
But when the response is in format like this:
[
{
"project": "Project Name 1",
"projectmanageremailaddress": "pmaddress1@mail.com"
},
{
"project": "Project Name 2",
"projectmanageremailaddress": "pmaddress2@mail.com"
}
]
I can't parse JSON inside the Power Apps with ParseJSON function nor by directly storing it to a variable or in any other way... The way how this source explains to parse JSON was not the answer to my question since they are parsing it directly inside the Power App and not as the response from API call (https://devoworx.net/powerapps-parse-json-examples/).
Anyhow I resolved this challenge by using Power Automate, and parsing JSON from there, storing it in a table and then using those data in Power Apps. However, if you could provide some POC for the above issue I would be grateful. Thank you.
@sdedic wrote:I was successful in populating labels when the response was returned as JSON string, but when it is returned as an array of objects I'm having a difficult time figuring out the solution.
This part isn't clear to me. You when you're returning "an array of objects", that is still just a JSON strong. The ParseJSON() function will parse it just fine. From Power Apps point of view, after parsing, you will have a table with records inside of it. You can use any of the normal methods that work on collections on the result.
MS.Ragavendar
32
Michael E. Gernaey
24
Super User 2025 Season 1
WarrenBelz
18
Most Valuable Professional