web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM to Hoopla Integration - Accessing Third Party Web Service Using OAuth

(0) ShareShare
ReportReport
Posted on by

Hello, 

I've been tasked to develop a CRM plugin that would use the Hoopla API (Sales Gamification) to load user metrics. i.e. We will be tracking new sales, therefore the plugin will listen for orders that go into Fulfilled status and then it will hit the Hoopla API, which is based on OAuth and JWT to grant access and rest calls to add the sale to the Hoopla/CRM user. 

I've already checked a few articles but no luck in finding any resources as to whether or not the plugin can authenticate using OAuth. Everything I can find regarding OAuth is for client applications and not web, or CRM plugin related for that matter. 

Thoughts?

Thanks in advance for any tips/suggestions/help. 

*This post is locked for comments

I have the same question (0)
  • abhishek_255 Profile Picture
    1,614 on at

    Hi,

    You can build a middle tier WCF/Rest service and have Hoopla API code wrapped in web method exposed to CRM plugin as HTTP Get or Post, endpoint binding could be one way, so that web service call in plugin will not wait for the response. You would get more flexibility in service compared to plugin.

    Best Regards,
    Abhishek

  • Community Member Profile Picture
    on at

    Hi efether,

    I recently have the same task to integrate CRM with Hoopla as well.

    I tried to use RestSharp to connect OAuth2. and then update Metric Value for user, but no result yet as there are no resources on website to follow.

    Do you have any progress? and share with me?

    Thanks in advanced.

  • Verified answer
    efefher Profile Picture
    on at

    Yes, this is what I did to make it work. Hopefully it helps you out. 

    First of all, you need to set the SecurityProtocol: 

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

    Then you need to use a HttpBasicAuthenticator, like this... 

    client = new RestClient("https://api.hoopla.net");

    client.Authenticator = new HttpBasicAuthenticator(**your_client_id**, **your_client_secret**);

    And then you can make the call to get the auth token and parse it out of the response. For that I did this. 

    RestRequest request = new RestRequest("/oauth2/token", Method.POST);
    request.AddHeader("content-type", "application/x-www-form-urlencoded");
    request.AddParameter("grant_type", "client_credentials");
    IRestResponse tokenResponse = client.Execute(request);

    // Get token from response
    if (tokenResponse.StatusCode == HttpStatusCode.OK)
    {
        Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(tokenResponse.Content);
        values.TryGetValue("access_token", out token); 
    }

    I placed all that code on a helper class to process all the rest transactions. 

  • efefher Profile Picture
    on at

    I forgot to mention, you also have to merge the additional assemblies you used, such as RestSharp into one assembly with ILMerge (www.microsoft.com/.../details.aspx) or add it to your project with Nuget package manager.

  • Community Member Profile Picture
    on at

    Cool. Thanks efefher.

    Throughout the weekend, I have created the two ways to get the access token. Both ways can get the token but since the restclient is an additional assemblies, I tried to use httpclient instead.

    1. Restclient

    2. httpclient

    - Then, I created a WF to trigger the httpclient plugin, the plugin able to get token (see the trace), but has error message as below and CRM keep retry in minute. Any suggestion on that?

    - Also, do you suggest a good guideline for using ILMerge?

    - After getting the token, I want to get user href, and update Metric value in Hoopla.

    How do you coding with that?

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected exception from plug-in (Execute): Interactive.MSCRM.Interactive.WF.UpdateTopOppuntity: System.TimeoutException: Couldn’t complete execution of the custom activity Interactive.MSCRM.Interactive.WF.UpdateTopOppuntity plug-in within the 2-minute time limit.Detail:

    <OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance&quot; xmlns="schemas.microsoft.com/.../Contracts&quot;>

    <ActivityId>6afdd71e-462b-4505-a33f-ee6bb3d44912</ActivityId>

    <ErrorCode>-2147220956</ErrorCode>

    <ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic&quot; />

    <Message>Unexpected exception from plug-in (Execute): Interactive.MSCRM.Interactive.WF.UpdateTopOppuntity: System.TimeoutException: Couldn’t complete execution of the custom activity Interactive.MSCRM.Interactive.WF.UpdateTopOppuntity plug-in within the 2-minute time limit.</Message>

    <Timestamp>2017-07-18T13:01:11.6083275Z</Timestamp>

    <ExceptionRetriable>false</ExceptionRetriable>

    <ExceptionSource>PluginExecution</ExceptionSource>

    <InnerFault i:nil="true" />

    <OriginalException>System.TimeoutException: Couldn’t complete execution of the custom activity Interactive.MSCRM.Interactive.WF.UpdateTopOppuntity plug-in within the 2-minute time limit.

    at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, String customActivityTypeName, IExecutionContext requestContext, Dictionary`2 sandboxServices, Boolean useDrawbridgeEnabled, Boolean chaosFailAppDomain)

    at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, String customActivityTypeName, IExecutionContext requestContext, Dictionary`2 sandboxServices, Boolean useDrawbridgeEnabled, Boolean chaosFailAppDomain)

    at Microsoft.Crm.Sandbox.SandboxWorker.ExecuteCustomWorkflowActivity(SandboxCallInfo callInfo, SandboxCustomActivityExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, SandboxRequestCounter& workerCounter, Boolean returnTraceInfo)</OriginalException>

    <TraceText>

    Hoopla: UpdateTopOpportunity Starting...

    Hoopla response:02463911949906ddaa9a9001/c6ea87b62882f25901926e9531d194a815052d626dde045d837ee5b234145ff61c791b417e954c345753aae68e7446812ea115e610c02763ed1ea3903ddc8fc5acb349a5173d1e46c13220c835fffcc6f67d3fa0124359f5920437ed90bb4eaa7d2627fbc31fd15357f5cb1f89446b92094b7123858b110bbb0a5b73f933c6f00dc62c34a17b9ce3e0cf2787ee156b4f319245bc929945a3733526291a48fe8951f5e15a2ff04a/dd63e5e46682fac4417b70b9abb6801b

    </TraceText>

    </OrganizationServiceFault>

    Thanks in advanced.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans