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:
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;
}
Comments
Post a Comment