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
Kim Yu NgKim Yu Ng 

Create OpenActivity thru REST

Is there a way to create Open Activities under Contact through rest api?
Best Answer chosen by Kim Yu Ng
@Karanraj@Karanraj
You have to use object name as 'Task'

All Answers

@Karanraj@Karanraj
Yes you can able to create open activites through REST API like a other normal record. Here is the JSON string to create open activites under the contact record
{
"WhoId"  : "0039000001tCKit",
"Subject" : "REST API"
}
Change the value of WhoId into the ID of the contact record to which you want to assign.
Kim Yu NgKim Yu Ng

I'm currently using `restforce` gem
```
client.create!('OpenActivity', Subject: "REST API", WhoId: "0039000001tCKit")

```

result: Faraday::ClientError: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: entity type cannot be inserted: Open Activity. Do you have any clue about this error? Is there any configuration that I missed it?

@Karanraj@Karanraj
You have to use object name as 'Task'
This was selected as the best answer
Kim Yu NgKim Yu Ng
Thanks! It works and that's awesome! How about Activity History? What would be the object name in this case?
@Karanraj@Karanraj
Use the same object and change the status of task into completed then it will be moved to activity history related list  Thanks, Karan
Kim Yu NgKim Yu Ng
You have been very helpful. I have no trouble to create an activity history anymore through the Task object name associated to Contact.
client.create!('Task', Subject: "Activities History Sample", WhoId: 'contact_id', Status: "Completed")

However, there is a caveat, when I was trying to associate to Contact and Account at the same time
client.create!('Task', Subject: "Activities History Sample 2", WhoId: 'contact_id', Status: "Completed", AccountId: "account_id")

The error is telling me this :
Faraday::ClientError: INVALID_FIELD_FOR_INSERT_UPDATE: Unable to create/update fields: AccountId. Please check the security settings of this field and verify that it is read/write for your profile or permission set

What should I do with this?
Alvin Dutt 6Alvin Dutt 6
Hi Kim, 

I am also wanting to do a similar task is it possible if you could share your Json or Http Post script