Skip to main content

Posts

Showing posts from March, 2020

Dynamic CRM call external API from the plugin

If you want to call external API from the plugin you need to use Newtonsoft.Json . You can use the below code. Note that in IP URL it is not working but it works with domain name URL: static async Task<bool> CallExternalAPI(Guid beziehungId) { //works bool status = false; HttpClient apiClient = new HttpClient(); apiClient.DefaultRequestHeaders.Accept.Clear(); apiClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); string url = @"https://reqres.in/api/users?page=2"; // Workin version test API URL HttpResponseMessage response = await apiClient.GetAsync(url); if (response.IsSuccessStatusCode) { var result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } return status; }