0
votes

I'm .NET Web Developer and new to Microsoft's CRM, so bear with me. I'm trying to find the correct way to connect to Microsoft Dynamics 365 and retrieve some PDF files. I need to know which is the correct way to do so. I have some questions of some topics found Googling around that don't make sense to me.

Accessing through the SDK

I have found this Microsoft documentation which explains the SDK. However there is a NOTE that says that this has changed with the 2016 update, and Googling more around, it seems to be that the SDK it's not used anymore. I am wrong?

Accessing data using Web API

There's yet another Microsoft documentation that tries to explain the way to connect through a Web Api, however from the start, it says: "This section contains reference documentation of the types, functions, and actions that constitute the Web API for Microsoft Dataverse and Dynamics 365 Customer Engagement (on-premises)".

That "On-Premises" comment bothers me. I don't want to learn something that doesn't work for me. Why the web api seems to work only on premise? Why not Dynamics in the cloud?

And for what you can see, I'm utterly confused as to how in the world I can access data to retrieve a file programmatically through C# code from Microsoft Dynamics 365 cloud based.

Please, if you can point me in the right direction, I will really appreciate it.

Thank you!

2

2 Answers

1
votes

If your language is C# you can use the SDK provided by Microsoft, it works with the Online (cloud) version.

If you are using .NET Framework you can use this NuGet package: https://www.nuget.org/packages/Microsoft.CrmSdk.XrmTooling.CoreAssembly/

If you are using .NET Core/.NET 5.0+ you can use this NuGet package (but in public preview): https://www.nuget.org/packages/Microsoft.PowerPlatform.Dataverse.Client/

Some details about these packages here: https://www.crmanswers.net/2021/05/microsoftpowerplatformdataverseclient.html

1
votes

Adding to Guido's excellent information here are a few more considerations:

Plugins and custom workflows are custom .NET assemblies where you would use the SDK. They currently only support the full .NET Framework.

To call into the system from a JavaScript library on a form (a.k.a. Client-side scripting), you'd use the WebAPI.

For console apps, web apps, and other external code, you can choose between the SDK and WebAPI. (And as Guido points out, the .NET Core version of the SDK is in preview).

When using the SDK there are two possible coding approaches: Early Bound and Late Bound.
With early bound, you generate proxy classes for DataVerse tables. The classes have properties for each column/attribute, which enables intellisense.

With late bound, you use the string names of tables and attributes. This article has more info.

Tools for generating early bound classes include Microsoft's CrmSvcUtil.exe, Daryl LaBar's Early Bound Generator in the XrmToolbox, and the commercial Visual Studio add-on for DataVerse XrmToolkit.

If you're going the WebAPI route, David Yack's API Helper might interest you.