Power Pages Portal Web API

In today’s digital age, managing data efficiently is crucial for any business. Power Pages Portal Web API offers a robust solution for performing CRUD operations on Microsoft Dataverse tables directly from your portal. This article will guide you through the steps to set up and use the Web API for these operations.

Prerequisites

Before diving into CRUD operations, ensure you have the following:

  • A Power Pages site version 9.3.3.x or later.
  • Proper table permissions configured for the Web API.
  • A basic understanding of HTTP requests and JSON.

Setting Up the Web API

  1. Enable Site Settings:
    • Open the Portal Management app.
    • Navigate to Site Settings.
    • Create new settings for enabling the Web API and specifying the fields that can be modified.

Site Settings Configuration

To enable CRUD operations for the Account table, configure the following site settings in the Site Settings table:

  1. Enable Web API for the Account Table:
    • Name: Webapi/account/enabled
    • Website: (Select your website)
    • Value: true
  2. Specify Fields for the Account Table:
    • Name: Webapi/account/fields
    • Website: (Select your website)
    • Value: name,primarycontactid,opportunity_customer_accounts
  3. Enable Detailed Error Messages (optional):
    • Name: Webapi/error/innererror
    • Website: (Select your website)
    • Value: true

Configure Permissions

Make sure you have table permissions set up for the Account table:

  1. Create a new Table Permission:
    • Name: Account CRUD Permission
    • Table: Account
    • Scope: Global
    • Permission: Create, Read, Update, Delete
  2. Assign the Table Permission to a Web Role:
    • Web Role: (Select the web role you want to assign the permission to)
    • Table Permission: Account CRUD Permission

Performing CRUD Operations

Create a Record

To create a new record in a table, use the following HTTP POST request:

json

POST [Portal URI]/_api/accounts
{
  "name": "Sample Account",
  "primarycontactid": {
    "firstname": "Alton",
    "lastname": "Stott"
  },
  "opportunity_customer_accounts": [
    {
      "name": "Opportunity associated to Sample Account",
      "Opportunity_Tasks": [
        {
          "subject": "Task associated to opportunity"
        }
      ]
    }
  ]
}

Read a Record

To read a record from a table, use the following HTTP GET request:

json

GET [Portal URI]/_api/accounts(00000000-0000-0000-0000-000000000001)?$select=*

Update a Record

To update an existing record, use the following HTTP PATCH request:

json

PATCH [Portal URI]/_api/accounts(00000000-0000-0000-0000-000000000001)
{
  "name": "Updated Account Name"
}

Delete a Record

To delete a record, use the following HTTP DELETE request:

json

DELETE [Portal URI]/_api/accounts(00000000-0000-0000-0000-000000000001)

Conclusion

The Power Pages Portal Web API provides a powerful way to manage your data directly from your portal. By following the steps outlined in this article, you can easily perform CRUD operations on your Dataverse tables, enhancing the functionality and user experience of your portal.


Discover more from BooNars

Subscribe to get the latest posts sent to your email.

Leave a comment