The context.webAPI exposed in custom controls (PFC) does not allow us to use the execute() method. Although not supported by MS the method is still possible to use.
You will need to cast the webAPI object into an variable of type any.
This is the code I used to successfully call a Custom API from a PCF. This should work with Custom Actions as well.
//execute custom api action
/*
<Action Name="sos_customapi_getcontactinfo">
<Parameter Name="ContactID" Type="Edm.Guid" Nullable="false"/>
<ReturnType Type="mscrm.sos_customapi_getcontactinfoResponse" Nullable="false"/>
</Action>
*/
// Execute request
var apiRequest = new class {
ContactID = {
guid: "934fd982-988c-eb11-b1ac-0022489bcf55"
};
getMetadata(): any {
return {
parameterTypes: {
ContactID: {
typeName: "Edm.Guid",
structuralProperty: 1
}
},
operationType: 0,
operationName: "sos_customapi_getcontactinfo"
};
}
}();
var anyWebAPI = <any>this.context.webAPI;
anyWebAPI.execute(apiRequest).then(
function success(response: any) {
console.log(response);
console.log(response.json());
},
function (errorResponse: any) {
// Error handling code here
console.log(errorResponse);
}
);
Dataverse, Power Platform
You must be logged in to post a comment.