title: Is it possible to call an Dynamics CRM action with a JSON request through a WebApi with IOrganizationService?
body: <p><strong>TL;DR:</strong></p>
  <p>I am calling a WebApi, the WebApi authenticates against the CRM and use the IOrganizationService, so my request is a JObject and not an Entity or EntityReference, it gives me this error:</p>
  <pre><code>Error: Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.
  </code></pre>
  <p><strong>Context:</strong></p>
  <p>I built a web application in angular and I built a WebApi so I can call some custom actions in CRM:</p>
  <p><strong>Angular APP | WebApi | OnPremise CRM</strong></p>
  <p>So, when I call the WebApi, there is a controller that turns my request into a OrganizationRequest:</p>
  <p><strong>Request for WebApi:</strong></p>
  <pre><code>{
      &quot;ActionName&quot;: &quot;custom_actionname&quot;,
      &quot;Parameters&quot;: 
      [
          {
              &quot;Key&quot;: &quot;EntityInputParameter1&quot;, 
              &quot;Value&quot;: {&quot;@odata.type&quot;:&quot;Microsoft.Dynamics.CRM.any_entity&quot;}
          }
      ]
  }
  </code></pre>
  <p>I read this request on my WebApi and turn that into a request for CRM</p>
  <p><strong>Request for CRM:</strong></p>
  <pre><code>OrganizationRequest request = new OrganizationRequest(&quot;custom_actionname&quot;);
  request.Parameters[&quot;EntityInputParameter1&quot;] = {&quot;@odata.type&quot;:&quot;Microsoft.Dynamics.CRM.any_entity&quot;} // This is a JObject
  OrganizationResponse response = service.Execute(request);
  </code></pre>
  <p>When I make the request, it gives me the following error:</p>
  <pre><code>Error: Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.
  </code></pre>
  <p>If I make the request directly to the action it works, but I cannot do that due security policies.</p>
  <p>One option could be turn the request into a valid CRM request (parsing <code>{&quot;@odata.type&quot;:&quot;Microsoft.Dynamics.CRM.any_entity}</code> into a <code>Entity</code> type) but CRM has a lot of parsing escenarios and could be very complex.</p>
  <p>Another option could be sending the request through web and stop using the <code>IOrganizationService</code> but I cannot change that.</p>
  <p>I am making this question so anybody that has this error can find the &quot;solution&quot; because I searched a lot and nobody refers this behavior directly.</p>
  <p>I am probably turning my InputEntityParameter into string, and I will send the JSON, so I can parse the JSON on my action, but I was looking if anybody else had this error or another approach.</p>