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 / Calling Powerapp CDS S...
Power Apps
Answered

Calling Powerapp CDS SDK methods in ASP Net Web API

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi Community,

 

We are working on to use Microsoft Common Data Services SDK methods in ASP Net Web API. When we are creating connection to the common data service, it is giving a prompt to sign in with azure id but after login it does not return response to web API to proceed further.

               

This is working fine when we are using the SDK methods inside console application, we are able to perform CRUD operations on CDS database from console application.

 

Please suggest how to use the SDK methods in ASP.Net web API? We want to avoid the login prompt as our application is a web API service which will run in background and there will no user interaction. Is there a way to define login credentials in config file or in code to avoid the login prompt?

 

Thanks

Categories:
  • v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    I have escalated your question to the pg. If they have any response later, I will notice you here.

     

    Regards,

    Mona

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Mona,

     

    Thanks for the update. Any further responses from PG? It's a critical step on which we stuck.

     

    Regards

  • v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    Could you please describe where you are providing the credentials? Are you using “on-behalf-of” sign-in, or are you trying to sign in a named user on the web tier?

     

    Are you correctly calling await on the creation of the client instance?

     

    using (var client = await ConnectionSettings.Instance.CreateClient())

    {}

     

    Do not use .Result in this case, on the web.

     

    Regards,

    Mona

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Mona,

     

    Thanks for your response.

     

    We are trying to provide the credentials in web config file of the ASP.Net web API but whenever we are calling the CreateClient method, the login prompt appears.

     

    Also We have tried calling await on the creation of the client instance, and not used Result, but in this case the control is returning to the client method without client creation. Since CreateClient is an async method, it will not wait for the response and return to the calling program, but we need client object to access the CDS entities. And if we are using Result in client creation without using await, it never returns a response.

     

     

    Thanks

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Mona,

     

    I there any update on this? This is critical for our CDS implementation, and we are stuck at this point.

     

     

    Thanks

  • Verified answer
    v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    Sorry for the delayed response. Here is the reply from pg:

     

    Can you tell me a little more about how the ASP.NET site does authentication? Is this by user, (so each user is registered in AAD), or is there one user that does the authentication?

     

    There is a flag that determines whether the prompt occurs:

     

    var settings = new ConnectionSettings()

    {

        Credentials = new UserCredentialsSettings()

        {

            UserName = "Name@microsoft.com",

            ApplicationId = "…",

            UserSource = UserSource.LoggedIn,

            //RedirectUri = "http://localhost",

        },

     

        EnvironmentId = "…",

        Tenant = "Microsoft.com",

    };

     

    using (var client = await settings.CreateClient())

    {

     

        Task.Run(() => DoItAsync(client));

     

        Console.WriteLine("Press any key...");

        Console.ReadLine();

     

    }

     

    The behavior you describe for the async is correct. The await would cause the control to transfer back to the calling method, but as soon as the client is created, the control would continue after the await.

     

    Regards,

    Mona

     

  • CU21051147-0 Profile Picture
    2 on at

    Hello,

     

    I am unable to connect with CDS SDK. I am getting an unexpected error

     

    "One or more errors occurred. (Method not found: 'Void Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters..ctor(Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior)'.)"

     

    on line "ConnectionSettings.Instance.CreateClient()"

     

    Can you please help me out?

     

    Regards,

    Zeshan Khan

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 239

Last 30 days Overall leaderboard