API Integration & Web API
The Power Pages Web API, and the difference between reading and writing
Post 22 covered calling other people’s APIs. This one’s about the one Power Pages gives you: the Web API, which lets client-side code read and write Dataverse directly.
It’s the piece that makes custom components possible. It’s also the piece people expose too broadly on their first attempt.
Step by step
1. Turn it on deliberately
The Web API is off by default and enabled per table through site settings. That’s the right design - you’re opening a data path to the browser, and it should be an explicit decision each time.
Enable the tables you need and list the fields. The * wildcard in Webapi/<table>/fields is deprecated, and requests against a table configured with it fail, so list the columns explicitly or put them in a system view named Power Pages Web API Columns. That’s the right outcome anyway: a wildcard exposes columns you forgot existed, and internal notes have a way of ending up in a payload someone reads.
2. Understand what still protects you
Table permissions apply. This is the important part, and it’s what makes the Web API safe to use: a request through it is subject to the same rules as anything else the signed-in user does.
Which also means an over-broad table permission is now over-broad in a place that’s easier to discover. Anyone can open dev tools and see the endpoint, so review your table permissions with that in mind.
3. Read
Query with the OData conventions - select the fields you need, filter server-side, order server-side, and take a page at a time.
Select explicitly. $select with a field list is smaller over the wire, faster to render, and doesn’t leak the column someone added last week.
Every call, reads included, carries the anti-forgery token: get it with shell.getTokenDeferred() and send it in the __RequestVerificationToken header. The session handles authentication; the token is what proves the request came from your page.
4. Write
Creates and updates go through the same endpoint with the appropriate verb, and need the matching permission - Create or Write - on the table.
Two things to get right. First, validate on the server, not just in your form: the Web API doesn’t care that your JavaScript checked the field length. Second, handle the failure cases - a rejected write needs to surface to the user, not disappear into a console log.
5. Deal with the shape of Dataverse
Lookups, option sets and dates are where client code usually gets messy. Lookups need the right binding format, option sets come back as numbers you have to map to labels, and dates need care around time zones - especially on a portal serving several of them.
Do the mapping in one place. Scattering it through the UI is how you end up with three different renderings of the same status value.
How to make a mess and fix it
404 on a table that definitely exists. The Web API isn’t enabled for it.
403 AttributePermissionIsMissing on a column. The column isn’t in the field list for that table.
403 for a user who should have access. Table permissions. The Web API is doing its job.
401 on every call. The __RequestVerificationToken header is missing.
Writes that seem to do nothing. They don’t fail quietly: you have Read but not Create or Write on that table, the API returns 403, and your code is swallowing it.
Data looks right but saves wrong. Almost always lookups or time zones.
Wrapping up
The Web API is what turns Power Pages from a configured portal into something you can build client-side functionality on. Enable it per table, list your fields explicitly, lean on table permissions rather than around them, and validate on the server regardless of what the browser already checked.
Useful links
- Web API overview and site settings
- Read operations
- Write, update and delete operations
- Handle HTTP requests and errors
- Table permissions
Next: custom authentication providers.