Call Dynamics Web API in C# Plugin

前端 未结 2 1651
情书的邮戳
情书的邮戳 2021-01-19 12:05

I have a Business Process Flow in Microsoft Dynamics to handle creation of a new client. When the process finishes, I am attaching a workflow that kicks of an action which c

相关标签:
2条回答
  • 2021-01-19 12:46

    I believe the issue was with the Plugin Registration Tool profiling a plugin execution. My follow up question is here.

    0 讨论(0)
  • 2021-01-19 13:08

    This blog states that we can make Web Api work in CRM on-premise (non-IFD) plugin by using WebClient with DefaultCredentials.

    using (WebClient client = new WebClient()) 
    {            
        client.UseDefaultCredentials = true;
        byte[] responseBytes = client.DownloadData(new Uri("<your web api url>/accounts(3C2D2712-E43F-E411-9402-005056AB452C)")); 
        string response = Encoding.UTF8.GetString(responseBytes);
        // parse the json response 
    }
    

    Make sure you specify the UseDefaultCredentials as true to make the web api call under the context of the user the plugin is running.

    We may struggle more with Online plugins because of Sandbox + Adal library + AAD tokens combo as we are trying in a non-interactive plugin code unlike other interface where we can challenge the user by prompt.

    Moreover Web api is more useful for cross platform, outside CRM context integration. Inside the platform execution you can use Org service to achieve more.

    0 讨论(0)
提交回复
热议问题