PowerPages Portal : DataVerse API -9004010A “An unexpected error occurred while processing the request
Recently we have been working on the Power Pages Portal to call Dataverse Web API and get data from the tables. For the sake of understanding let us say we need to get data from Account(system table) but same concepts applies for Custom tables also.
So ideally the endpoint URL should have been
https://yourorgname.powerappsportals.us/_api/accounts(bxxxx3-axx9-exx1-8xxa-001xxxxxxa)
But when we were trying to get using AJAX Code, we were getting below error
{ "error": { "code": "9004010A", "message": "An unexpected error occurred while processing the request" } }
After spending some time, we figured out it was due to the fact that the Site Settings entries were missing for the target table in our case table with the name ‘account’.
So to fix this what we would have to do is go to Portal Management Site settings and Add two entries for every entity type for which we need to expose web API for this site.
First entry is to enable the Web API and 2nd one is to enable which fields to be exposed.
The Name of the first entry should be Webapi/<yourentityname>/enabled
The Name of the 2nd entry should be Webapi/<yourentityname>/fields
We can do selective field exposure also, if you just wanted API to only return certain fields but if you need all the fields to be exposed you can use *
Below is how the Site settings would look
Another Note – Please make sure you are using the plural name of entities to get data, the logical name and schema name will not work. it has to be plural name.
After doing these two entries you would be able to get data using Web API.
Hope this helps…. Happy Coding..!!!
Ref URL – https://dynamics-chronicles.com/article/powerapps-portal-webapi-introduction-and-how-call-custom-d365-actions