Hi Experts,
I am trying to write a plugin in D365 CE to call external WebAPI in my case Business Central so i am making a call for the bearer token once and then the actual URL. But the code just exits at the place where the external call is made. I created a console application and checked and it works fine but the plugin keeps failing.
So i checked with a simple WebApi call but that also failed and it always fails right when it makes the external call, this works fine on a console application but fails on a plugin, below is the sample code that fails.
public static async Task GetbearerToken(ITracingService tracing){var client88 = new HttpClient(); client88.BaseAddress = new Uri(https://jsonplaceholder.typicode.com//); HttpResponseMessage response88 = await client88.GetAsync(/todos/1/); if (response88.IsSuccessStatusCode) { string content22 = await response88.Content.ReadAsStringAsync(); }}
I tried debugging the code, when i come to the line HttpResponseMessage response88 = await client88.GetAsync(/todos/1/); it exits, i have tried with var response = await client88.GetAsync(/todos/1/); it exits and it switches to the plugin registration tool with the message below, but in visual studio the process on the Diagnostic Session just goes on as it would after we attach the process to Pluginregistrationtool.exe and before we select the class file
Profiler> Plug-in AppDomain Created
Profiler> Parsed Profiler File Successfully.
Profiler> Constructor Execution Started: 09/07/2023 19:10:27
Profiler> Constructor Execution Completed Successfully (Duration = 0ms).
Profiler> Profiler Execution Started: 09/07/2023 19:10:27
Profiler> Profiler Execution Completed Successfully (Duration = 26724ms).
Profiler> Profiler AppDomain Unloaded
Please let me know if has anything changed or am i doing anything wrong, kindly help.
​