Error during Consuming WEB API in PLUGIN +CRM 2015 RRS feed

  • Question

  • Hi Folks,

    I am creating a POST CREATE Plugin wherein I am consuming a WEB API by posting the entity Id retrieved from the context.

    However I Get the Business Process Error.

    I am using the following code:

     Entity entity = ((Entity)context.InputParameters["Target"]);

    tracingService.Trace("Retrieved Entity Account from context. Entity Id is " + entity.Id.ToString());

    if (entity == null || entity.LogicalName != "account")
                    using (var client = new HttpClient())

    client.BaseAddress = new Uri("serveraddress");

    //Used server address because I can't post links now

    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                        tracingService.Trace("Retrieve Response");
                        HttpResponseMessage response = client.PostAsJsonAsync("api/CRM", entity.Id.ToString()).Result;
                        tracingService.Trace("Retrieved Response");
                        string successcode = response.IsSuccessStatusCode.ToString();
                        tracingService.Trace("successcode: " + successcode);
                        tracingService.Trace("Response: " + response.ToString());
                        if (response.IsSuccessStatusCode)


    Response is returned as

    successcode: False
    Response: StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
      Pragma: no-cache
      Cache-Control: no-cache
      Date: Wed, 01 Apr 2015 06:54:30 GMT
      Server: Microsoft-IIS/8.5
      X-AspNet-Version: 4.0.30319
      X-Powered-By: ASP.NET
      Content-Length: 36
      Content-Type: application/json; charset=utf-8
      Expires: -1

    Not able to Debug it.

    Using Plugin isolation mode as None.

    The code works if I am not using a Plugin.

    Please help.



    Wednesday, April 1, 2015 7:13 AM

All replies

  • Hello,

    Looks like you have error on internal endpoint side.

    Dynamics CRM MVP
    My blog

    Thursday, April 2, 2015 12:23 PM