/// <inheritdoc/> public async Task <HttpResponseMessage> RegisterWorkforceIntegrationAsync(Models.RequestModels.WorkforceIntegration workforceIntegration, GraphConfigurationDetails graphConfigurationDetails) { var provider = CultureInfo.InvariantCulture; this.telemetryClient.TrackTrace(BusinessLogicResource.RegisterWorkforceIntegrationAsync + " called at " + DateTime.Now.ToString("o", provider)); var httpClient = this.httpClientFactory.CreateClient("GraphBetaAPI"); var requestUrl = "teamwork/workforceIntegrations"; var requestString = JsonConvert.SerializeObject(workforceIntegration); return(await this.SendHttpRequest(graphConfigurationDetails, httpClient, HttpMethod.Post, requestUrl, requestString).ConfigureAwait(false)); }
/// <summary> /// Method to call the Graph API to register the workforce integration. /// </summary> /// <param name="workforceIntegration">The workforce integration.</param> /// <param name="accessToken">The access token.</param> /// <returns>The JSON response of the Workforce Integration registration.</returns> public async Task <HttpResponseMessage> RegisterWorkforceIntegrationAsync( Models.RequestModels.WorkforceIntegration workforceIntegration, string accessToken) { var provider = CultureInfo.InvariantCulture; this.telemetryClient.TrackTrace(BusinessLogicResource.RegisterWorkforceIntegrationAsync + " called at " + DateTime.Now.ToString("o", provider)); var requestString = JsonConvert.SerializeObject(workforceIntegration); var httpClientWFI = this.httpClientFactory.CreateClient("GraphBetaAPI"); httpClientWFI.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); httpClientWFI.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "teamwork/workforceIntegrations") { Content = new StringContent(requestString, Encoding.UTF8, "application/json"), }) { var response = await httpClientWFI.SendAsync(httpRequestMessage).ConfigureAwait(false); return(response); } }