Compilation fails
mkalinovTC opened this issue · comments
Hello @JimDaly and community,
I have forked the Samples for Dataverse part. Compilation of any solution fails due to absence of proper references (using) in cs files.
WebAPIService Service class does not contain definitions of Retrieve, Create and other methods but they are refenced in samples.
Is there something I miss?
@mkalinovTC
Thanks for reporting this.
First thing, please make sure you are using VS 2022. If you are using VS 2019 it won't work correctly since these are .NET 6.0 samples.
Second, can you tell me exactly which solution you tried to open and what you saw?
Finally,
Each sample solution has a project dependency on WebAPIService. The Service class has only the SendAsync method.
Create, Update, Retrieve, and other Methods are extensions so you must include these using statements:
using PowerApps.Samples;
using PowerApps.Samples.Messages;
using PowerApps.Samples.Methods;
@JimDaly
Thanks Jim,
I use VS 2019 with .NET 6.0 (Preview 4, May 2022) installed and functional.
The first solution I tried to open is WebAPIService itself.
More then 200 files in the solution are missing references.
For example, the attached screenshot shows Messages/InitializeFromRequest.cs which lacks:
using System;
using System.Collections.Generic;
using System.Net.Http;
Regarding the create, update etc u're correct, it happens because WebAPIService cannot be compiled.
@mkalinovTC
You need to use VS 2022. These projects were developed and tested only using VS 2022.
You can use Visual Studio Community.
See : https://dotnet.microsoft.com/en-us/download/dotnet/6.0
Thanks Jim, u're cotrrect
Please let us know if you run into any other issues.
Hmm, I try to move the to OAuth2 S2S (n0 interactive-user). I see the only Microsoft.IdentityModel.Clients has option of client secret authentication. All MSAL options are for user and/or B2C. Shall we stay with previous Microsoft Identity(ADAL, which is deprecated) platform or I miss something again?
@mkalinovTC
You shouldn't stay on ADAL.
This sample doesn't focus on Authentication. As called out here: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/samples/webapiservice
This library does not:
- Manage authentication. It depends on a function passed from an application that will provide the access token to use. All Web API samples depend on a shared App class that manages authentication using the Microsoft Authentication Library (MSAL). MSAL supports several different types of authentication flows. These samples use the Username/password (ROPC) flow for simplicity but this is not recommended. For your apps, you should use one of the other flows. More information: Authentication flow support in the Microsoft Authentication Library.
In other words, the sample expects to be passed a function that will return an access token. How that token is generated is up to the developer.
Other than registering the application using AAD and granting the appropriate permissions, the rest is all about using MSAL. You should find resources needed here: Authentication flow support in MSAL