Upload File - v2.1

Updates in V2.1

1. A new parameter has been added:

  • In V2.1, by default, all associated workflows will get triggered. skip_workflow parameter key allows the restriction of schedules and form workflows. In API V2, this provision of skipping certain workflows is not possible.

Overview

This API updates a file to a file upload, image, audio, video, or signature field of a specific record, which is present in a Zoho Creator application.

  • Refer to this section for the file types that these fields accept
  • The upload operation will be subject to the custom data validations configured for the corresponding form
  • The file you upload will be counted towards the file storage limit of the the account in which the target application exists. Visit the account's usage details page to view its current storage details.

Request Details

Request URL

https://<base_url>/creator/v2.1/data/<account_owner_name>/<app_link_name>/report/<report_link_name>/<record_ID>/<field_link_name>/upload

Request method

POST

Header

KeyValueDescription
Authorization

Zoho-oauthtoken

1000.8cb99dxxxx

xxxxxxxxx9be93.9

b8xxxxxxxxxxxxxxxf

An authentication token (authtoken) allows users to access apps and APIs without having to enter their login credentials each time.
environmentdevelopment/stageRefers to the environment stage.
Note: By default, production value will be considered for the environment header.

OAuth scope

scope=ZohoCreator.report.CREATE

where,

base_urlthe base URL of your Creator account
For example, it's www.zohoapis.com if your account belongs to Zoho's US DC, and is www.zohoapis.com if it belongs to Zoho's EU DC.
account_owner_namethe username of the Creator account's owner
app_link_namethe link name of the target application
report_link_namethe link name of the target report
record_IDthe ID of the record that you want to upload the file
field_link_namethe link name of the target file upload, image, audio, video, or signature field

Parameters

  • skip_workflow list

    (Optional) Prevents the associated workflows from being executed while uploading a file. You can choose to skip form workflows and/or schedules. When more than one type of workflow is mentioned, the parameter values should be supplied as comma separated values in a list.
    Possible values: form_workflow, schedules, all

    Note: By default:

    • If this parameter is not supplied, all associated workflows will be triggered.
    • Blueprints and approvals will be triggered while files are updated, and cannot be skipped.
    Sample value for the parameter "skip_workflow"Description
    "skip_workflow" : ["schedule","form_workflow"]Prevents the associated schedules and form workflows from being triggered when the file is uploaded using API
    "skip_workflow" : ["schedules"]Prevents the associated schedules when the file is uploaded using API 
    "skip_workflow" : ["all"]Prevents the associated schedules and form workflows from being triggered when the file is uploaded using API

File Types and Limits

Possible Errors

Refer to this page for the list of error codes and messages.

Sample Request for Production environment (for C6 users)

Copiedcurl "https://www.zohoapis.com/creator/v2.1/data/jason18/zylker-store/report/Inventory_Report/3888834000000114050/Product_Manual/upload?skip_workflow=["schedules","form_workflow"]"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copiedfile = invokeUrl
[
	url: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    type: GET
];
file.setParamName("file");
	
response = invokeUrl
[
   	url: "https://www.zohoapis.com/creator/v2.1/data/jason18/zylker-store/report/Inventory_Report/3888834000000114050/Product_Manual/upload?skip_workflow=[\"schedules\",\"form_workflow\"]"
   	type: POST
   	connection: "zoho-creator"
	files: file
];
	
info response ;
Copiedpackage main.java.org.example;

import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.String;
import java.io.File;

public class UploadApi
{
    public static void main(String[] args) throws JSONException
    {
        OkHttpClient client = new OkHttpClient();

        String filePath = "target_file_path";

        File file = new File(filePath);

        MediaType mediaType = MediaType.parse("application/octet-stream");
        RequestBody requestBody = new MultipartBody.Builder()
                .setType(MultipartBody.FORM)
                .addFormDataPart("file", file.getName(),
                        RequestBody.create(mediaType, file))
                .build();

        HttpUrl.Builder urlBuilder = HttpUrl.parse("https://www.zohoapis.com/creator/v2.1/data/jason18/zylker-store/report/Inventory_Report/3888834000000114050/Product_Manual/upload").newBuilder()
                .addQueryParameter("skip_workflow", "[\"schedules\",\"form_workflow\"]");
        Request request = new Request.Builder()
                .url(urlBuilder.toString())
                .method("POST", requestBody)
                .addHeader("Authorization", "Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf")
                .build();
        try
        {
            JSONObject response = new JSONObject(client.newCall(request).execute().body().string());
        }
        catch (Exception e)
        {
            System.out.println("Exception while making the API request.");
        }
    }
}
Copiedlet api_headers = {
    "Authorization": "Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
}

const parameters = {
  "skip_workflow": '["schedules","form_workflow"]'
}

let filePath = 'target_file_path';

fs.readFile(filePath, (err, data) => {
    if (err) {
        console.error('Error reading file:', err);
        return;
    }

    let formData = new FormData();
    formData.append('file', data)

    try {
        let response = fetch("https://www.zohoapis.com/creator/v2.1/data/jason18/zylker-store/report/Inventory_Report/3888834000000114050/Product_Manual/upload", {
            method: "POST",
            headers: api_headers,
            body: formData,
            params: parameters
        })
    }
    catch (exception) {
        console.error(exception)
    }
});
Copiedimport requests

api_headers = {
    "Authorization": "Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
}

parameters = {
    "skip_workflow": "[\"schedules\",\"form_workflow\"]"
}

file_path = 'target_file_path'

with open(file_path, 'rb') as file:
    files = {'file': file}

    try:
        response = requests.post("https://www.zohoapis.com/creator/v2.1/data/jason18/zylker-store/report/Inventory_Report/3888834000000114050/Product_Manual/upload", headers=api_headers, files=files, params=parameters)
    except:
        print("Exception while making the API request.")

This sample request uploads a file to the Product_Manual field of the record with ID 3888834000000114050, which is displayed in the Inventory Report of the Zylker Store application.

Sample Request for Development/ Stage environments (for C6 users)

Copiedcurl "https://www.zohoapis.com/creator/v2.1/data/jason18/zylker-store/report/Inventory_Report/3888834000000114050/Product_Manual/upload?skip_workflow=["schedules","form_workflow"]"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-H 'environment: development' 

Sample Input (multipart/form-data)

Copied{
  "file": "target_file_path"
}

Sample Response

Copied{
  "code": 3000,
  "filename": "Screen Shot 2019-12-20 at 10.56.27 AM.png",
  "filepath": "1580987985461_Screen_Shot_2019-12-20_at_10.56.27_AM.png",
  "message": "File uploaded successfully !"
}