Merge and Store

Purpose

Using this API, you will be able to store the merged document inside Zoho Docs or Workdrive.

HTTP Request URL

https://{zohoapis_domain}/writer/api/v1/documents/{{document_id}}/merge/store

Path Parameters

ParameterData TypeDescription
Mandatory Parameters
document_idStringSpecify a unique id for the writer document.

Body Parameters

ParameterData TypeDescription
Mandatory Parameters
output_settings

'doc_name': "<new document name>",

'folder_id': "<folder_id>" ,    

'output_format':"<pdf/docx/pdfform>",

'password': "<*****>",    

'overwrite_existing_file': "<true/false>"

}

 

Pass the values for 'doc_name' and 'folder_id' via this parameter as JSON.

doc_name -> Specify the name for the merged document.

folder_id -> Specify the id of the folder in which you would like to store the merged document.

output_format (optional) -> Supported formats are pdf, pdfform and docx. Specify a format in which you would like to store the merged document.

If this key is not passed, the merged documents will get stored in Writer format (zdoc) by default.

password (optional) -> Specify a password if you would like to protect the merged document. This param is applicable only for pdf and docx documents.

overwrite_existing_file (optional) -> Use this param, if you wish to replace an existing file stored in Zoho WorkDrive with the merged document.

You can provide the data in any one of the below formats
merge_dataJSONObjectPass a String value through 'data' key as JSON Array.
merge_data_csv_contentFileProvide the required csv content in your API request body.
merge_data_json_contentFileProvide the required json content in your API request body.
merge_data_csv_urlurlProvide the required csv url in your API request body.
merge_data_json_url urlProvide the required json url in your API request body.

Note:

  • To use this API, an OAuth token should be generated with the following scopes ZohoWriter.documentEditor.ALL and ZohoWriter.merge.ALL 
  • If you would like to store the documents (docx/pdf) inside a Workdrive/Docs folder, you need to include the following scopes accordingly;

           -> For Workdrive - WorkDrive.Files.ALL
           -> For Docs - ZohoPC.files.ALL

  • We have also provided an option to configure the values for all the above parameters while creating the document itself.
  • If you have saved the merge settings earlier by configuring the parameter values, then we will get those values (by default) if you miss to pass the parameters while sending the API request.
  • To avoid the DRE timeout exception, we have introduced Merge and Store V2 API. For more details, please refer this link.

Sample Request


				curl --location --request POST "https://zohoapis.com/writer/api/v1/documents/ponazfea04477109f4681a831e7177d96bc40/merge/store" \
  --header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
  --form "output_settings={\"doc_name\":\"New Document\",\"folder_id\":\"azfa093747109f4681\"}" \
  --form "merge_data={\"data\":[{\"name\":\"Amelia\",\"email\":\"amelia@zylker.com\"}]}"			

Sample Response


				{
"document_id": "ponazfea04477109f4681a831e7177d96bc40",
"document_url": "http://writer.zoho.com/writer/open/ponazfea04477109f4681a831e7177d96bc40",
"status": “success”
}			

Snippet


				document_id = "fbsa6360a78f53f564dfa9b4a1e79febed569";
fieldInfo =  zoho.writer.getMergeFields("fbsa6360a78f53f564dfa9b4a1e79febed569","writer_crm");
fieldsList =  fieldInfo.get("fields");
data = map();
for each field in fieldsList
{
 info field;
}	
data.put("Name", "Ms.P");
data.put("Tamil", "S");
data.put("English", "A");
data.put("Maths", "A");
data.put("Remark", "Good");
output_settings = Map();
output_settings.put("doc_name","writer mergeandstore newdoc");
info zoho.writer.mergeAndStore(document_id,data,output_settings,"writer_crm");			

Sample Response


				{
"document_id": "ponazfea04477109f4681a831e7177d96bc40",
"document_url": "http://writer.zoho.com/writer/open/ponazfea04477109f4681a831e7177d96bc40",
"status": “success”
}