hi
Could you please advise on best way to set
parentcustomerid_account
to null using web api ?
thank you
*This post is locked for comments
hi
Could you please advise on best way to set
parentcustomerid_account
to null using web api ?
thank you
*This post is locked for comments
This is seriously messed up. If I would like to remove five lookup values I need to send five delete messages...
I'm sad now.
Thank you for help, I have different issue now:
Could you please help with the following scenario ? I am running this code to delete a reference parentcustomerid_account
This is working successfully on DEV but when executed on different environment IFD / ADFS the request is 404 NOT FOUND
Do you have any idea ? Thank you
// [Org URI]/api/data/v8.2/contacts([contactid#])/parentcustomerid_account/$ref
contact1Uri = httpClient.BaseAddress + web_api + "contacts(" + myReader.Value.ToString
().ToLower() + ")/parentcustomerid_account/$ref";
HttpResponseMessage disassocResponse1 = await httpClient.DeleteAsync(contact1Uri);
if (disassocResponse1.StatusCode == HttpStatusCode.NoContent)
Status code is 404 = NOT FOUND
Same code is successful on different environment
Thank you for your help, it was not straight forward for me
EDIT: just noticed you seem to have figured it out:)
Hi,
you don't need to send both guids to delete - as Scott mentioned, you just need to use this kind of url for the delete request:
.../api/data/v8.2/contacts(CONTACTID)/parentcustomerid_account/$ref
I manage to get everything done in 2 steps
- get account if for parentaccountid
- send delete request for disassociation.
Thank you for your help, it is not straight forward
contact1Uri = httpClient.BaseAddress + "v8.0/contacts(" + myReader.Value.ToString().ToLower() + ")";
//queryOptions = "?$select=fullname,annualincome&$expand=parentcustomerid_account($select=name)";
queryOptions = "?$select=fullname&$expand=parentcustomerid_account($select=accountid,name)";
HttpResponseMessage retrieveResponse1 = await httpClient.GetAsync(contact1Uri + queryOptions);
if (retrieveResponse1.StatusCode == HttpStatusCode.OK) //200
{
retrievedContact1 = JsonConvert.DeserializeObject<JObject>(
await retrieveResponse1.Content.ReadAsStringAsync());
Console.WriteLine("Contact Fullname {0}", retrievedContact1.GetValue("fullname"));
Console.WriteLine("Contact parentcustomerid_account {0}", retrievedContact1["parentcustomerid_account"]["accountid"]);
contactToDissasociateUri = httpClient.BaseAddress + "v8.0/accounts(" + retrievedContact1["parentcustomerid_account"]["accountid"].ToString().ToLower() + ")/contact_customer_accounts/$ref?$id="+ httpClient.BaseAddress + "v8.0/contacts(" + myReader.Value.ToString().ToLower() + ")";
HttpResponseMessage disassocResponse1 =
await httpClient.DeleteAsync(contactToDissasociateUri);
if (disassocResponse1.StatusCode == HttpStatusCode.NoContent)
{
Console.WriteLine("Contact '{0}' dissociated from account '{1}'.",
retrievedContact1["fullname"], retrievedContact1["parentcustomerid_account"]["name"]);
}
else
{
Console.WriteLine("Failed to disassociate entities for reason: {0}.",
disassocResponse1.ReasonPhrase);
throw new CrmHttpResponseException(disassocResponse1.Content);
}
Console.ReadKey();
Thank you for reply, looks like I need to send both guids:
- contact id
- account id ( that needs to be set to null)
Probably I am too new to this ...
The request should look like this
"xxxx/.../contact_customer_accounts$ref?$id=xxx/.../contacts(guid_contact)"
Which is very strange as I only need to set existing parent account to NULL, why do I need to send the existing value if that is going to be NULL anyway?
Also, I have issue when I tried to extract existing value if you can help
"?$select=fullname,annualincome&$expand=parentcustomerid_account($select=name)";
Hi,
You have to send a DELETE request.
E.g.
DELETE [Organization URI]/api/data/v8.2/opportunities(00000000-0000-0000-0000-000000000001)/customerid_account/$ref
From msdn.microsoft.com/.../mt607875.aspx
It is a bit odd - but this is the way that the OData spec defines it should be done!
Hope this helps
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156