ramu
ramu

Reputation: 1

How to Call a custom connector API from Power App Canvas

I have a custom connector to create a new user as POST, I have created a new Power App canvas with user details input form fields to create a new user. How to use custom connector to send a POST request to create new user with the details entered in the canvas APP?

The online example i see are explaining to "consume" data from the custom data connector, are there any references that explain how to post data to custom connector?

Upvotes: 0

Views: 2077

Answers (1)

DaveS
DaveS

Reputation: 3294

POST [Organization URI]/api/data/v9.0/accounts HTTP/1.1
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json

{
    "name": "Sample Account",
    "creditonhold": false,
    "address1_latitude": 47.639583,
    "description": "This is the description of the sample account",
    "revenue": 5000000,
    "accountcategorycode": 1
}

(source: https://learn.microsoft.com/en-us/powerapps/developer/data-platform/webapi/create-entity-web-api)

This shows an example of a POST request to create a new record in an entity (or a new row in a table if you're using normal industry terms). The example is how you'd build the POST endpoint in your custom connector. You just need to define the field names you want to use (not the values the example shows).

So, once your post endpoint has been added to your custom connector, you can use it in your canvas app in a button's OnSelect, for example. Let's say your custom connector is called CustomConnector, and your endpoint is called myPost, then you'd do something like

CustomConnector.myPost({
    "name": "Sample Account",
    "creditonhold": false,
    "address1_latitude": 47.639583,
    "description": "This is the description of the sample account",
    "revenue": 5000000,
    "accountcategorycode": 1
})

Documentation about calling a custom connector endpoint: https://learn.microsoft.com/en-us/connectors/custom-connectors/use-custom-connector-powerapps#add-formulas-to-drive-behavior

Upvotes: 1

Related Questions