| Muhammad Yaseen
Power Apps Portal Web API
Portals Web API are used to perform CUD (Create, Update, Delete) Operation, and for Reading purpose we have a FetchXml which works fine, Before Web API we need to rely only on provided standard functionality - forms (entity and web) on creating/updating records, entity lists on showing lists of records. And this was limiting especially from a user experience perspective. With the introduction of Portal Web API, we can create complex custom experiences - creative forms, editable lists and much more.
Web API and Site Settings
By default, Web API on the portal is disabled. To enable it you need to configure it support per entity as a site setting.
Furthermore, you need to specify which fields will be available for web API as another site setting.
Both these options give you more control over the security of your data (unlike odata entity list option).
Also, you can enable the ability to see inner Web API error with the next setting
For example we want to enable Web API for contact entity for first name, last name and email address. Our setting will look like this:
To perform any action you will need to send a request to correct URL (api + entityset name), simple example will be if you want to create contact you will send POST request with json payload to next url YOUR_PORTAL_URL/_api/contacts.
Microsoft also provides the convenient Ajax wrapper function which you just have to use in portal pages. Portals Web API write, update, and delete operations - Power Apps | Microsoft Docs.
If you wants little more understading about this Wrapper Ajax function you can check below link,
Example for update Method:
You simply have to use type patch and provide the entity name in URL with column unique identifier, I picked using liquid template functionality, and in json.stringyfy you have to provide the columns you wants to update with key value pair in Json format,
I also create its success and error function on which you can handle what you want to process after the successful or failed result
Microsoft also provide the CUD template for easiness.
Join us next time, as we continue our journey of learning canvas apps.Click here to learn more about Imperium's Power Apps Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.