web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PCF-React Control Usin...
Power Apps
Unanswered

PCF-React Control Using webAPI

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi Folks,

Im a frontend developer and new to PCF and Powerapps component framework. I'm trying to retrieve data from an entity using retriveRecord but was not working even after deployed. 

This is the code which i have used in the pcf control.I'm aware about the webAPI not supported in the test harness but In the test harness at least I'm getting the error response. After deploying the control we are not getting any success or error console logs.

 

We are also getting a authentication error from skype-sdk file.

 

(the id and entity logical name is dummy here)

 

const retriveData=async () => {
console.log("log from retriveData");
let id="1";
let filter=`$select=firstname,lastname`;
let options="";
props.pcfContext.webAPI
 .retrieveRecord("leads", id, filter)
 .then(successCallback, errorCallback);
 };
const successCallback= (response: any) => {
console.log(response, "WebApi succss Response");
alert("sucess");
 };
const errorCallback= (errorResponse: any) => {
console.log(errorResponse, "WebApi error Response");
alert("error");
 };

 

 

 

Any help work appreciate!

Krishna

I have the same question (0)
  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @Anonymous 

    I think it's only a small issue: is should be "lead", not "leads":

     

    props.pcfContext.webAPI
     .retrieveRecord("lead", id, filter)
     .then(successCallback, errorCallback);

     

    And because successCallback and errorCallback are declared with const (not function), they should be declared before using them.

    Hope this helps!

     

    Kind regards,

    Diana 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @DianaBirkelbach 

     

    Thanks for your replay, and I tried this but it still remains the same. I tried to log the context in the console. And Its not showing the available webAPI methods like retrieveRecord under the webAPI. It should show these methods there right? then only we can consume it.

     

    utils: e {_customControlProperties: {…}, _externalUtils: {…}, _globalCommandManagerInitialized: false, _internalEventListeners: Array(1), doesControlExist: ƒ, …}
    webAPI: e
    __proto__: Object
    __proto__: Object
    webapi-null.PNG
  • a33ik Profile Picture
    3,306 Most Valuable Professional on at

    @Anonymous did you enable webapi in ControlManifest.Input.xml? It should look like following:

     <feature-usage>
     <uses-feature name="Utility" required="true" />
     <uses-feature name="WebAPI" required="true" />
     </feature-usage>
     
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @a33ik 

     

    yes I have added those. and in the test harness it throwing error response (retrieveRecord method). But after deploying it , looks like it not executing the method.

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @Anonymous ,

    It should work then. You are testing in a Model-Driven, and not in a CanvasApp, right?

    Kind regards,

    Diana

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @DianaBirkelbach 

     

    we are trying to import this pcf control into a Microsoft dynamics 365. It is Model-Driven right?

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @Anonymous ,

    I have an example where only "utils" were activated in the manifest, but not the "webAPI", and is looking exactly like in your screenshot:

    DianaBirkelbach_0-1601558315840.png

    It looks like the webAPI is not activated in your control.

    In case you activated first the "utils", and the webAPI later on, maybe you have a problem with the upload of your component (so maybe it didn't made the update correctly).
    Do you use "pac pcf push" to upload the PCF?

    Kind regards,

    Diana

    PS: Yes, Dynamics 365 is ModelDriven App 🙂

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

     

     

    Yes @DianaBirkelbach , we are using "pac pcf push" to upload the PCF control.

     

     

    Kind Regards

    Krishna

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @Anonymous ,

     

    Then I also think that it should work. Here is all I can still think of:

    1.  the webAPI functions are visible in the console only when you open the "__proto__" property (Screenshot below), so maybe it's still there. I just wonder, why you have the __proto__ listed twice.

    DianaBirkelbach_0-1602068855750.png

     

     2. delete the PCF from your form

     3. check again in the manifest that webApi feature is set to true (as @a33ik described)

     4. If you use "pac pcf push", this will generate the content of the solution inside as subfolder of your project. Check out here "\obj\PowerAppsTools_<yourPrefix>\bin\Debug\PowerAppsTools_<yourPrefix>.zip", and check inside of your manifest if the features are correct. Check if you have included some other content in the zip that shouldn't belong there.

     5. register again the PCF on the form.

     6. If it still doesn't work, you could try to make a dummy webAPI request right inside your updateView method. I see that you use props.pcfContext which makes me think that maybe you've passed the pcf context as props inside a React component. Maybe is a react issue.

     

    If that still doesn't work, I'm afraid I have no ideas anymore... Wish you luck!🍀

     

    Hope it helps!

    Kind regards,

    Diana

     

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @Anonymous , 

     

    Did this or something else solve your issue? 

     

    Kind regards,

    Diana

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 525 Most Valuable Professional

#2
Haque Profile Picture

Haque 273

#3
Kalathiya Profile Picture

Kalathiya 232 Super User 2026 Season 1

Last 30 days Overall leaderboard