We will start with the 100% helpful Microsoft docs articles:
https://docs.microsoft.com/en-us/powerapps/maker/portals/web-api-overview
https://docs.microsoft.com/en-us/powerapps/maker/portals/web-api-perform-operations
I haven’t had any issues with simple type fields but I stuck with lookups. Remembering my first time exploring the portal Web API, I didn’t run into this issue. Or maybe it worked slightly differently during that times.
There are some articles in Internet which are helpful to degree but I still couldn’t get it working.
I was experimenting and while making another change to the code started getting the following error:
“An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property ‘my_property’ which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values”
This is how I found this article of Carl De Souza 💖
And these steps from his article helped me to resolve my issue:

“To resolve this, we need to go to the Entity Definitions. Browse out to the Entity Definitions at https://yourorg.crm.dynamics.com/api/data/v9.1/$metadata#EntityDefinitions and under your entity, find the new attribute created, in my case, the field created is called new_appointmentleader:

We see that the NavigationProperty name is new_AppointmentLeader_Appointment. If we use this in the request instead
In my case, for fields sas_portaluser and regardingobjectid
<NavigationProperty Name="sas_PortalUser_sas_PortalActivity" Type="mscrm.contact" Nullable="false" Partner="sas_PortalActivity_PortalUser_Contact">
<ReferentialConstraint Property="_sas_portaluser_value" ReferencedProperty="contactid"/>
</NavigationProperty>
and
<NavigationProperty Name="regardingobjectid_account_sas_portalactivity" Type="mscrm.account" Nullable="false" Partner="account_sas_PortalActivities"/>
I had to code it like this:
function addPortalActivity() {
var recordObj = {
"subject":"Dashboard Accessed for the client - {{user.parentcustomerid.name}} ",
"description":"The dashboard has been accessed by a portal user - {{user.fullname}}",
"sas_type":"100000050",
"sas_PortalUser_sas_PortalActivity@odata.bind":"/contacts({{user.Id}})",
"regardingobjectid_account_sas_portalactivity@odata.bind":"/accounts({{accountid}})"
};
appAjax('Adding...', {
type: "POST",
url: "/_api/sas_portalactivities",
contentType: "application/json",
data: JSON.stringify(recordObj),
success: function (res, status, xhr) {
recordObj.id = xhr.getResponseHeader("entityid");
}
});
return false;
}
addPortalActivity();
To finalize this, you have to update it in the settings as well:

1 thought on “Power App Portal Web API – fighting lookups”