Hello,
I've written a plugin which consumes a business central web service.
It works great when the server's response is 200.
When the server's reponse is 500 (internal server error) I need to show the user the error message. The problem is that I think I'm not getting the error message.
When I consume the web service from postman or Wizdler, I get an error like this:
When I consume the web service from the plugin, I only get this:
How am I supposed to get the error and show it to user?
here is part of the code:
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Stream responseStream = response.GetResponseStream(); string responseStr = new StreamReader(responseStream).ReadToEnd(); string result = responseStr; context.OutputParameters["resultString"] = result; } else if(response.StatusCode == HttpStatusCode.InternalServerError) { string result = response.StatusDescription; context.OutputParameters["resultString"] = result; } } } catch (FaultException ex) { throw new InvalidPluginExecutionException("An error occurred in FollowUpPlugin.", ex); } catch (Exception ex) { tracingService.Trace("FollowUpPlugin: {0}", ex.ToString()); throw; } }