cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Power Apps Code Component : Unauthorized 401 error while making API call to CDS in PCF (Code Components) embedded Canvas App, context.userSettings is null #CanvasApps Code Component

Hi All,

I am using PCF control in my canvas app which is embedded in form. In my PCF code I am making API call to get data from CDS, I am getting 401 unauthorized error, when I debugged it then I noticed the context.userSettings property doest have data.

hemantkumar_0-1599122362471.png


Could someone help me with it, how to fix it?
Does any one have faced the same issue? Not sure if its possible or not.

Thanks in advance
Hemant

 

3 REPLIES 3
Solution Sage
Solution Sage

You haven't told us what you are trying to do but PCF components in a Canvas App do not have access to the WebApi as it's possible for a component to be embedded in a Canvas App that doesn't have a CDS environment attached to it.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

Hi @ben-thompson ,

Thank you for the quick response.

I am trying to get the list of entities and calling EntityDefinitions using HTTP request. Will it be possible?

Many thanks
Hemant

Not via a webapi call using Xrm.WebApi.

 

Possibly by making webapi requests using XMLHttpRequest direct to the server but you won't know without trying.

 

Edit to add - I think the context.userSettings bit is irrelevant here - you don't need to create a new connection, you just want to use the permissions and connection the browser already has.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Users online (27,553)