title: How to pass data.bind in POST request using C#
body: <p>i have a web app connected with crm Dynamics 365. I want to create record in an entity using API, but the entity has lookup fields to another entities. I tried this code but it gives bad request error. How can i send the values of the lookup fields in the API?</p>
  
  <pre><code>JSON:{
  "msdyn_name": "Asset",
  "msdyn_account@odata.bind": "/accounts(7f7e031b-0e20-ea11-a810-000d3a2d54fd)",
  "new_externalproj@odata.bind": "/msdynce_externalprojects(ee3f03c6-751f-ea11-a810-000d3a27b751)" }
  </code></pre>
  
  <pre><code>
  var serializer = new JavaScriptSerializer();
  string json = serializer.Serialize(new
  {
       msdyn_name = "Asset",
       msdyn_account = "7f7e031b-0e20-ea11-a810-000d3a2d54fd",
       new_externalproj = "ee3f03c6-751f-ea11-a810-000d3a27b751"
  });
  var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://XXX.dynamics.com/api/data/v9.1/msdyn_customerassets");
  httpWebRequest.Method = "POST";
  httpWebRequest.Headers.Add("Authorization", String.Format("Bearer {0}", result.AccessToken));
  httpWebRequest.Headers.Add("OData-MaxVersion", "4.0");
  httpWebRequest.Headers.Add("OData-Version", "4.0");
  httpWebRequest.ContentType = "application/json";
  
  using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
  {streamWriter.Write(json);
  }
  var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
  using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
  {
  var responseText = streamReader.ReadToEnd();
  }
  
  
  </code></pre>