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

PowerApp cuts off an API response

Hello,

 

I am working with a Custom Connector to an API. On a GET (all) call, I get info back from the API. The info is not consistent. About 25% of items in the response have the field that I want. The other 75% of the items do not have the field that I want. That is to say that the item does not have that key at all.

 

For example, I want "thingId":

25%

"name": "something",

"thingId": "123",

"type": "text",

 

75%

"name": "something",

"type": "text",

 

PowerApps cuts off "thingid" and other fields like it. In Advanced Tools > Monitor, I can see a 200 code. The response has all the info, including the fields that PowerApps cuts off. If an item has the field, it appears. The other 75% of the time, the field will appear in the monitor as "No value" This is still OK, and not yet a problem. 

 

The problem is when I set this result to a variable, the field that I want is removed. It is completely gone. Not even a null.

 

Does anyone have any ideas about this? Any similar stories? Fixes?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @aa12 :

I'm not sure if I understand your requirement.If there is any problem please let me know:

  • The data structure of the return value of this API is an object.Something like:
{
        "name":"something",
        "thingId":"123",
        "type":"text"
    }
  • The return value of this API is uncertain,Sometimes the specified field "thingId" will not be returned

Sometimes its data structure is like this

{
        "name":"something",
        "thingId":"123",
        "type":"text"
    }

 Sometimes its data structure is like this

 {
        "name":"something",
        "type":"text"
    }
  •  You are currently using the set function to save the return value of this API to a variable.
  • When the return value of this API does not contain thingId, the thingid column in your variable will disappear.

I assume my understanding is correct.

Firstly,let me explain why you encountered this problem:

The function of Set is to set the variable with the value you set, so the data structure of this variable depends on the value you set. If you only have one Set function to define this variable, then the data structure of this variable depends entirely on the data structure of the return value of your API.

Secondly,my suggestion is to create another set() formula that will never be executed to set the data structure of this variable. for example:

Create an invisible button

OnSelect

Set(thevar,{
        name:"something",
        thingId:"123",
        type:"text"
    }
)

 Visible

false

The advantage of this is that even if the event will never be executed, it can guarantee that there must be three text-type fields (name\thingId\type) in the variable thevar.

Best Regards,

Bof

View solution in original post

2 REPLIES 2
v-bofeng-msft
Community Support
Community Support

Hi @aa12 :

I'm not sure if I understand your requirement.If there is any problem please let me know:

  • The data structure of the return value of this API is an object.Something like:
{
        "name":"something",
        "thingId":"123",
        "type":"text"
    }
  • The return value of this API is uncertain,Sometimes the specified field "thingId" will not be returned

Sometimes its data structure is like this

{
        "name":"something",
        "thingId":"123",
        "type":"text"
    }

 Sometimes its data structure is like this

 {
        "name":"something",
        "type":"text"
    }
  •  You are currently using the set function to save the return value of this API to a variable.
  • When the return value of this API does not contain thingId, the thingid column in your variable will disappear.

I assume my understanding is correct.

Firstly,let me explain why you encountered this problem:

The function of Set is to set the variable with the value you set, so the data structure of this variable depends on the value you set. If you only have one Set function to define this variable, then the data structure of this variable depends entirely on the data structure of the return value of your API.

Secondly,my suggestion is to create another set() formula that will never be executed to set the data structure of this variable. for example:

Create an invisible button

OnSelect

Set(thevar,{
        name:"something",
        thingId:"123",
        type:"text"
    }
)

 Visible

false

The advantage of this is that even if the event will never be executed, it can guarantee that there must be three text-type fields (name\thingId\type) in the variable thevar.

Best Regards,

Bof

View solution in original post

aa12
Microsoft
Microsoft

Hello,

 

Thanks for the help. I would also like to submit a fix.

After further research, I think the issue is in the response field in the Custom Connector API screen. 

I entered my response. It was something like this:

{

"count": 2,
"value": [
{
"name": "something",
"thingId": "123",
"type": "text"
},
{
"name": "somethingelse",
"type": "text"
}
]
}

 

Notice that the items are not the same.

The Custom Connector created a response body WITHOUT thingId.

 

When I entered this one below, which omits the second one that is missing the thingId, the Custom Connector creates the right response body. 

 

{

"count": 1,
"value": [
{
"name": "something",
"thingId": "123",
"type": "text"
}
]
}

 

The one above gives me what I want. This is unexpected behavior for sure. 


Thanks for your help!

Helpful resources

Announcements
PA 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 Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (62,648)