Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

plugin stops when making external webapi call

(0) ShareShare
ReportReport
Posted on by 1,299
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.
  • Verified answer
    Davyjones Profile Picture
    1,299 on at
    plugin stops when making external webapi call
    Thank you very much, we got around the issue by not using async task but just the normal way

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,125 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,871 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans