function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sebastian TarachSebastian Tarach 

How to assign Contact to Case via REST API

Hi,
I'm unable to assign a ContactId to Case.
I input ContactId the request goes through but either Contact Name, Email and Phone are empty and when I query that Case ContactId field is also empty.
AnudeepAnudeep (Salesforce Developers) 
Hi Sebastian- Do you have any triggers on case? I suggest capturing debug logs. Also, can you try doing a POST using the following URL and JSON

URI : /services/data/v47.0/sobjects/Case
Operation : POST 
Body: JSON
 
{
    "ContactId": "0032xxxxxxxxxxxxxx",
    "AccountId": "0012xxxxxxxxxxxxxx",
    "AssetId": null,
    "SuppliedName": null,
    "SuppliedEmail": null,
    "SuppliedPhone": null,
    "SuppliedCompany": null,
    "Type": "Mechanical",
    "Status": "New",
    "Reason": "Equipment Design",
    "Origin": "Web",
    "Subject": "Inadequate headroom with installation of aircon unit",
    "Priority": "Medium",
    "Description": null,
    "Comments": null
}

If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!

Anudeep
Sakshi Nawab 11Sakshi Nawab 11
Hi Sebastian,
Instead of "POST" HTTP method , you can try using : "PATCH" with below request query : (It worked for me as well :), it updated contact Id on case)

/services/data/v48.0/sobjects/Case/5007F00000lXnt6(GIVE YOUR OWN CASE ID HERE)

{
    "ContactId": "0037F00000O4qBk" //GIVE YOUR CONTACT ID TO GET UPDATED IN CASE OBJECT