I have a C# plugin in Dynamics 2016 on-premise that uses a library to make calls to other systems. Part of that library is a call to dynamics using the Web
I remember this issue, when I was debugging SharePoint online REST API calls it will always crash. Then I added tracing service & logged checkpoints to verify the code execution path. Instead of debugging, I will download the Profiler trace log & replay in PRT to see success or failure branch.
When you configure plugin tracing to log All under system settings, it’s Dev mode & will be super helpful.
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
try
{
tracingService.Trace("Attempting to obtain Phone value...");
phone = account["telephone1"].ToString();
}
catch(Exception error)
{
tracingService.Trace("Failed to obtain Phone field. Error Details: " + error.ToString());
throw new InvalidPluginExecutionException("A problem has occurred. Please press OK to continue using the application.");
}
Reference
In your case:
if(responseMessage != null)
{
tracingService.Trace("API call success & got responseMessage.");
}
else
{
tracingService.Trace("responseMessage was empty.");
}