Announcements
string url = "">...........crm.dynamics.com";
var query = "/api/data/v9.1/pfna_test3s";
JObject pfna_test3 = null;
pfna_test3 = new JObject();
);
pfna_test3["pfna_name"] = "Test";
pfna_test3["pfna_lookup@odata.bind"] = "/pfna_test2s(GUID)";
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(url);
httpClient.Timeout = new TimeSpan(0, 2, 0);
httpClient.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0");
httpClient.DefaultRequestHeaders.Add("OData-Version", "4.0");
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
HttpRequestMessage request1 = new HttpRequestMessage(HttpMethod.Post, url + query);
request1.Content = new StringContent(pfna_test3.ToString(),System.Text.Encoding.UTF8, "application/json");
HttpResponseMessage response1 = await httpClient.SendAsync(request1);
I am getting bad request .....
pfna_test3s is my table and it has a field titled 'pfna_lookup' which looks into pfna_test2s...
How can i have the create a record with lookup ... I can create with non look up field ... Please help
Hi,
Schema name of lookup field which you are passing is incorrect. I would recommend you to download Rest Builder tool and generate code from there to use in your c# code.
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/
Hi,
Please refer to the following blog which may help you.
André Arnaud de Cal...
294,125
Super User 2025 Season 1
Martin Dráb
232,871
Most Valuable Professional
nmaenpaa
101,158
Moderator