Set CRM Lookup Values with WebAPI
<p>Who had done CRM Web API calls to update CRM entities with Lookup values from another Entity.</p>

<p>I'm trying to set a Lookup Value to another Entity within CRM using WebAPI, CRM 2016.  It works if I disable the Lookup value but once I enable the Lookup value, I receive Bad Request.  </p>

<p>Below is my code in LinqPad so it does work.</p>

<pre><code>void Main()
{   
using(var webClient = new WebClient()){
    webClient.Credentials = new NetworkCredential("Username", "Password", "Domain");
    webClient.Headers.Add("OData-MaxVersion", "4.0");
    webClient.Headers.Add("OData-Version", "4.0");
    webClient.Headers.Add("accept", "application/json");
    webClient.Headers.Add("Content-Type","application/json");
    webClient.Headers.Add("Prefer", "odata.include-annotations=*");         

    webClient.BaseAddress = "http://dev.company.com/DEV2016/api/data/v8.0/";

    var JO = new JObject();
    JO.Add("col_name","My Name");
    //JO.Add("col_contactid@odata.bind","/contacts(7266f26b-7105-e611-811e-005056b61789)");
    var dataString = JO.ToString();

    var responseString = webClient.UploadString("col_advisors", "POST", dataString);

    Console.WriteLine(webClient.ResponseHeaders.Get("OData-EntityId"));
}
}
</code></pre>