Update Subform Data
Purpose
To update a record with subforms in a module.
Endpoints
- PUT /{module_API_name}
Request Details
Request URL
{api-domain}/crm/{version}/{module_API_name}
Supported modules
Leads, Accounts, Contacts, Deals, Campaigns, Cases, Solutions, Products, Vendors, Quotes, Sales Orders, Purchase Orders, Invoices and custom modules.
Header
Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52
Scope
scope=ZohoCRM.modules.{module_name}.{operation_type}
Possible module names
leads, accounts, contacts, deals, campaigns, cases, solutions, products, vendors, quotes, salesorders, purchaseorders, invoices and custom.
Possible operation types
ALL - Full access to a record
WRITE - Create, update, and delete records in a module
UPDATE - Update records in a module
Sample Request
Copiedcurl "https://www.zohoapis.com/crm/v8/Contacts"
-X PUT
-d "@updatecontact.json"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copieddata1 = Map();
data1.put("id", "692969000000983046");
data1.put("Languages", [{"id":"692969000000983047"},{"id":"692969000000983048","Proficiency":"Native","Languages_Known":"Korean"}]);
dataList = List();
dataList.add(data1);
param = Map();
param.put("data", dataList);
response = invokeurl
[
url: "https://www.zohoapis.com/crm/v8/Leads"
type: PUT
parameters: param.toString()
connection:"crm_oauth_connection"
];
info response;
In the request, @updatecontact.json contains the sample input data.
Note
To update multiple subforms, enter the input in the following format.
{ “data”: [ { .... Subform_1_API_name: [ { sub_form_data }, ], ... }, { .... Subform_2_API_name: [ { sub_form_data }, ], ... } ] }
- You can use the Modules API and Fields Metadata API to get the API name of the subform module and its fields, respectively.
- You must specify the record ID either in the request URL or the input body.
- When you update an existing subform record, you must include the subform record's ID inside the subform's JSON array. You can use the Get Records API with the Subform's API name to get the ID of the subform records. For example, {api-domain}/crm/v8/Secondary?fields=Secondary_Email. Here, Secondary is the API name of the subform.
Refer to the sample input for an example. - From V3, when you update a subform by adding a new record, the new record is appended to the subform and the old records remain unaffected.
- When you pass an empty JSON array for the subform, it deletes all the records in that subform.
- To delete a specific subform record, specify that subform record's ID and the key _delete with the value "null". Refer to the Sample Input section for an example.
- Deleting a parent record also deletes all subform records.
Sample Input to update an existing subform record
Copied{
"data": [
{
"id": "554023000000480721",//contact id
"Languages": [
{
"id":"554023000000480787",//id of the subform record
"Proficiency": "Native",//data to be updated
"Languages_Known": "French"//data to be updated
}
],
"Availability": [
{
"id": "554023000000480728",//id of the subform record
"Weekdays": false//data to be updated
}
]
}
]
}
Sample Input to add a new subform record
Copied{
"data": [
{
"id": "554023000000480721",//contact id
"Languages": [
{
"Proficiency": "Pofessional"
}
]
}
]
}
Sample Input to delete a subform record
Copied{
"data": [
{
"Languages": [
{
"id": "554023000000480721",//contact ID
"_delete": null
}
]
}
]
}
Possible Errors
- INVALID_MODULEHTTP 400
You have either specified an invalid module API name, there is no tab permission, or the module is removed from the list of available modules.
Resolution: Use the Modules API to get the API name of the module. If you have no tab permission or the module is removed, contact your system administrator. - INVALID_MODULEHTTP 400
The given module is not supported in API.
Resolution: The modules such as Documents and Projects are not supported in API, currently. This error will not be shown, once these modules are supported. - INVALID_DATAHTTP 400
You have given an incorrect input.
Resolution: Specify a valid input. Refer to the Sample Input section for an example. - MANDATORY_NOT_FOUNDHTTP 400
You have not included one or more mandatory fields in the input.
Resolution: Refer to the Fields Metadata API to know the mandatory fields in that module. - AUTHORIZATION_FAILEDHTTP 400
You do not have sufficient permission to update subform or module records.
Resolution: Contact your system administrator. - INVALID_REQUEST_METHODHTTP 400
The request method is incorrect.
Resolution: Use the HTTP PUT method to make this API call. Any other request method will result in this error. - AUTHENTICATION_FAILUREHTTP 401
You have not authenticated the API call with a valid access token.
Resolution: Include a valid access token in the request header to authenticate the API call. - OAUTH_SCOPE_MISMATCHHTTP 401
The access token you have used to make this API call does not have the required scope.
Resolution: Generate a new access token with the scope ZohoCRM.modules.{module_name}.{operation_type}. Refer to the Possible module names and Possible operation types sections for details. - NO_PERMISSIONHTTP 403
You do not have permission to update records of the subform.
Resolution: Contact your system administrator. - INVALID_URL_PATTERNHTTP 404
The request URL is incorrect.
Resolution: Specify a valid request URL. Refer to the Request URL section for the right URL. - INTERNAL_ERRORHTTP 500
Unexpected and unhandled exception in the server.
Resolution: Contact the support team at support@zohocrm.com.
Sample Response
Copied{
"data": [
{
"code": "SUCCESS",
"details": {
"Modified_Time": "2019-04-23T17:31:02+05:30",
"Modified_By": {
"name": "Patricia Boyle",
"id": "554023000000235011"
},
"Created_Time": "2019-04-23T16:57:01+05:30",
"id": "554023000000480721",
"Created_By": {
"name": "Patricia Boyle",
"id": "554023000000235011"
}
},
"message": "record updated",
"status": "success"
}
]
}