cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Spawn10
Level: Powered On

How do I bind my custom API to a dropdown control?

I created a custom API with which I want my app to bind to. After creating the custom API, I test it and get data.

I then attempt to bind this to a Dropdown control and keep getting this error "The property expects Table values, but this rule produces incompatible Boolean values". The screenshot below shows how I am doing it...being new to PowerApps, this might just be user error. I just want to display the 'Name' data in the dropdown control. What am I doing wrong here?

 

Thanks for the help.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: How do I bind my custom API to a dropdown control?

Your connector may be incorrectly or incompletely configured.

Let's walk through it quick;

 

First, manually go and get a response from <yourAPIendpointURL>api/WellOperator in your browser.

Go to PowerApps Custom connectors and edit your custom connector.

I assume you cleaned it up and filled in the blanks (summary and description fields) when you created it initially. 

Find the action under "Definition" that calls <yourAPIendpointURL>api/WellOperator (one of the GetAll actions from the swagger which you may have renamed to GetAllWellOperator if I look at your PA images).

Under the "Response" section for the action, click on the "200 OK" response block.

 

In the Response Body section you should see response parameters ID and Name - if not, you need to import an example response for PA to understand the parameters coming back from the call.

 

Click on Import From Sample.

In the Body section, paste the output of the manual browser call you made to <yourAPIendpointURL>api/WellOperator earlier.

Click Import - you should then see the ID and Name parameters appear in your Response Body section.apiresponse3.PNG

 

Now - update your connector and wait 15 minutes.

This is usually the case when creating custom connectors - so if you decide to recreate from scratch you have to wait 15min before they start working - (well, I do anyway) - I'm not sure if you have to wait when editing and updating connectors, but if you test straight away and it doesn't work, just wait 15min and test again before you go fiddling with settings again.

 

Head back to PowerApps and test - you might want to create a new button and dropdown just to make sure you're working off a clean slate - you may even want to remove the connector and re-add it or just fire up a fresh new app to make sure.  I used your swagger to build a custom connector of my own and here's the results;

 

I used a button to;

ClearCollect(collectAPIresponse, DGO_FDC_WebAPI.GetAll())

Remember, the original Swagger had a whole bunch of GetAll() actions that used different URI's.  I didn't rename any, I just deleted everything except the one I wanted.  You may still be using GetAllWellOperator() for yours.

Here's the result in the View, Collection menu;

apiresponse.PNGThe collection

And the screen;

apiresponse.jpg

 

 

You can see the dropdown property .Name works as the dropdown is populated with all the names returned.

 

Hope this helps 🙂

 

Kind regards,


RT

 

View solution in original post

7 REPLIES 7
Super User
Super User

Re: How do I bind my custom API to a dropdown control?

Hi spawn10,

 

It's a little hard to tell without knowing the full structure of your JSON response for that particular function.  I'm also not sure the gallery is clever enough to construct a JSON response as a table directly.

 

What I would suggest is, intead of binding the call directly to the Items property of a gallery, try collecting it first;

Collect(collectAPIresponse, DGO_FDC_WebAPI.GetAllWellOperator())

Then go have a look at it in your Collections view.  If you can see some data, then add the collection to the Items property of the gallery instead;

Items: collectAPIresponse

 

Hope this helps,

 

RT

Spawn10
Level: Powered On

Re: How do I bind my custom API to a dropdown control?

Thank you so much for the response RusselThomas. I am able to follow your suggestions and able to move forward, however the data isn't being displayed. I my binding is in a dropdown and trying to just bind the "Name" field. Right now, the collection is returning a Boolean when there data available.

Collect(collectAPIresponse, DGO_FDC_WebAPI.GetAllWellOperator())

Any pointers on how to get around this?

Super User
Super User

Re: How do I bind my custom API to a dropdown control?

Hi spawn10,

 

Apologies, in my first response I read 'gallery' instead of 'dropdown'.  The primary difference being that you would need to specify a specific column of data for a list of dropdown items.  Assuming there was data there to begin with, the items property for the dropdown would then be something like;

 

Items: collectAPIresponse.Name

 

But as it doesn't appear to contain data, and I unfortunately can't see your API definition, I'm afraid I can't really answer you.  In your first post you showed what looked like a JSON response - there appeared to be more than just a boolean result in there - where did that come from?  What other functions are available in the API?

 

Kind regards,


RT

 

 

Spawn10
Level: Powered On

Re: How do I bind my custom API to a dropdown control?

The JSON response came from the test I ran, when I created the custom API connector in PowerApps. This is what he definition looks like...attached.

I had tried "Items: collectAPIresponse.Name" and that gave me issues as well. Something is definitely happening that I am not aware of.

Super User
Super User

Re: How do I bind my custom API to a dropdown control?

ok, gottit - you may want to remove your definition from your post in the meantime.

Will take a look and come back to you.

 

RT

Super User
Super User

Re: How do I bind my custom API to a dropdown control?

Your connector may be incorrectly or incompletely configured.

Let's walk through it quick;

 

First, manually go and get a response from <yourAPIendpointURL>api/WellOperator in your browser.

Go to PowerApps Custom connectors and edit your custom connector.

I assume you cleaned it up and filled in the blanks (summary and description fields) when you created it initially. 

Find the action under "Definition" that calls <yourAPIendpointURL>api/WellOperator (one of the GetAll actions from the swagger which you may have renamed to GetAllWellOperator if I look at your PA images).

Under the "Response" section for the action, click on the "200 OK" response block.

 

In the Response Body section you should see response parameters ID and Name - if not, you need to import an example response for PA to understand the parameters coming back from the call.

 

Click on Import From Sample.

In the Body section, paste the output of the manual browser call you made to <yourAPIendpointURL>api/WellOperator earlier.

Click Import - you should then see the ID and Name parameters appear in your Response Body section.apiresponse3.PNG

 

Now - update your connector and wait 15 minutes.

This is usually the case when creating custom connectors - so if you decide to recreate from scratch you have to wait 15min before they start working - (well, I do anyway) - I'm not sure if you have to wait when editing and updating connectors, but if you test straight away and it doesn't work, just wait 15min and test again before you go fiddling with settings again.

 

Head back to PowerApps and test - you might want to create a new button and dropdown just to make sure you're working off a clean slate - you may even want to remove the connector and re-add it or just fire up a fresh new app to make sure.  I used your swagger to build a custom connector of my own and here's the results;

 

I used a button to;

ClearCollect(collectAPIresponse, DGO_FDC_WebAPI.GetAll())

Remember, the original Swagger had a whole bunch of GetAll() actions that used different URI's.  I didn't rename any, I just deleted everything except the one I wanted.  You may still be using GetAllWellOperator() for yours.

Here's the result in the View, Collection menu;

apiresponse.PNGThe collection

And the screen;

apiresponse.jpg

 

 

You can see the dropdown property .Name works as the dropdown is populated with all the names returned.

 

Hope this helps 🙂

 

Kind regards,


RT

 

View solution in original post

Highlighted
Spawn10
Level: Powered On

Re: How do I bind my custom API to a dropdown control?

Thank you so much! The definition was definitely the issue. Following the steps you outlined, solved the issue.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,276)