Zoho Projects API Documentation
Text copied
File not found

Attachments

This module covers attachment related operations within Zoho Projects. Use this API to retrieve, upload, associate, or disassociate attachments for projects.

Get Project Attachments

Get attachments details by Entity id

GET

/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments

OAuth Scope:

ZohoProjects.portals.READ, WorkDrive.workspace.ALL,Workdrive.team.ALL,WorkDrive.files.ALL

Path Parameters

Param Name
Data Type
Description

Query Parameters

Param Name
Data Type
Description

Request Example

Request Example
  • cURL
  • Deluge
  • Node.js
  • Ruby
  • PHP
  • Python
  • C
  • C#
  • C++
  • Clojure
  • Go
  • HTTP
  • Java
  • JS Fetch
  • JSON
  • Kotlin
  • Objective-C
  • OCaml
  • PowerShell
  • R
  • Swift

curl -X GET \
'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments?entity_type=task&entity_id=1752587000000097299' \
-H 'Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments";
params = Map();
params.put("entity_type", "task");
params.put("entity_id", "1752587000000097299");
response = invokeUrl
[
    url: url
    type: GET
    parameters: params
    connection: "projects"
];
info response;
const https = require('https');
const url = new URL('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments');
url.searchParams.append('entity_type', 'task');
url.searchParams.append('entity_id', '1752587000000097299');

const options = {
  hostname: url.hostname,
  path: url.pathname + url.search,
  method: 'GET',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(JSON.parse(data)); });
});

req.on('error', (err) => { console.error(err); });
req.end();
require 'net/http'
require 'uri'
require 'json'

url = URI("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments")
params = {
  "entity_type" => "task",
  "entity_id" => "1752587000000097299"
}
url.query = URI.encode_www_form(params)

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"

response = http.request(request)
puts response.read_body
<?php
$params = [
    'entity_type' => 'task',
    'entity_id' => '1752587000000097299',
];
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments" . "?" . http_build_query($params);

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
import requests

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments"

params = {
    "entity_type": "task",
    "entity_id": "1752587000000097299"
}

headers = {
    "Authorization": "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
}

response = requests.get(url, headers=headers, params=params)

print(response.json())
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl) {
        char *enc_entity_type = curl_easy_escape(curl, "task", 0);
        char *enc_entity_id = curl_easy_escape(curl, "1752587000000097299", 0);
        char url[2048];
        snprintf(url, sizeof(url), "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments?entity_type=%s&entity_id=%s", enc_entity_type, enc_entity_id);

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");

        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));

        curl_free(enc_entity_type);
        curl_free(enc_entity_id);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
using System.Net.Http;
using System.Text;
using System.Web;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

var query = HttpUtility.ParseQueryString(string.Empty);
query["entity_type"] = "task";
query["entity_id"] = "1752587000000097299";
var uriBuilder = new UriBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments") { Query = query.ToString() };
var request = new HttpRequestMessage(HttpMethod.Get, uriBuilder.Uri);

var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
    output->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;
        char* enc_entity_type = curl_easy_escape(curl, "task", 0);
        char* enc_entity_id = curl_easy_escape(curl, "1752587000000097299", 0);
        std::string url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments";
        url += "?entity_type=" + std::string(enc_entity_type);
        url += "&entity_id=" + std::string(enc_entity_id);

        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK)
            std::cout << response << std::endl;
        else
            std::cerr << curl_easy_strerror(res) << std::endl;

        curl_free(enc_entity_type);
        curl_free(enc_entity_id);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
(require '[clj-http.client :as client])

(let [enc-entity_type (java.net.URLEncoder/encode "task" "UTF-8")
      enc-entity_id (java.net.URLEncoder/encode "1752587000000097299" "UTF-8")
      url (str "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments" "?entity_type=" enc-entity_type "&entity_id=" enc-entity_id)]
(def response
  (client/get url
    {:headers {"Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"}
     :as :json}))

(println (:body response))
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
)

func main() {
    req, _ := http.NewRequest("GET", "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments", nil)
    q := req.URL.Query()
    q.Add("entity_type", "task")
    q.Add("entity_id", "1752587000000097299")
    req.URL.RawQuery = q.Encode()
    req.Header.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
GET https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments?entity_type=task&entity_id=1752587000000097299 HTTP/1.1
Host: https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments?entity_type=task&entity_id=1752587000000097299
Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();

URIBuilder uriBuilder = new URIBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments");
uriBuilder.addParameter("entity_type", "task");
uriBuilder.addParameter("entity_id", "1752587000000097299");
HttpUriRequest requestObj = new HttpGet(uriBuilder.build());
requestObj.addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

HttpResponse response = httpclient.execute(requestObj);

HttpEntity responseEntity = response.getEntity();
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
const url = 'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments';

const params = new URLSearchParams({
  'entity_type': 'task',
  'entity_id': '1752587000000097299'
});

const options = {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

fetch(url + '?' + params.toString(), options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));
entity_type = "task"
entity_id = "1752587000000097299"
import java.net.HttpURLConnection
import java.net.URL
import okhttp3.HttpUrl.Companion.toHttpUrl

fun main() {
    val urlBuilder = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments".toHttpUrl().newBuilder()
    urlBuilder.addQueryParameter("entity_type", "task")
    urlBuilder.addQueryParameter("entity_id", "1752587000000097299")
    val url = URL(urlBuilder.build().toString())
    val conn = url.openConnection() as HttpURLConnection
    conn.requestMethod = "GET"
    conn.setRequestProperty("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    val response = conn.inputStream.bufferedReader().readText()
    println(response)
}
NSString *encodedEntity_type = [@"task" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *encodedEntity_id = [@"1752587000000097299" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *urlString = [NSString stringWithFormat:@"https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments?entity_type=%@&entity_id=%@", encodedEntity_type, encodedEntity_id];
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"GET"];
[request setValue:@"Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa" forHTTPHeaderField:@"Authorization"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@", result);
}];
[task resume];
open Lwt
open Cohttp_lwt_unix

let () =
  let enc_entity_type = Uri.pct_encode "task" in
  let enc_entity_id = Uri.pct_encode "1752587000000097299" in
  let uri = Uri.of_string ("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments" ^ "?entity_type=" ^ enc_entity_type ^ "&entity_id=" ^ enc_entity_id) in
  let headers = Cohttp.Header.init ()
    |> fun h -> Cohttp.Header.add h "Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  in
  Lwt_main.run (
    Client.get ~headers uri >>= fun (_, body) ->
    Cohttp_lwt.Body.to_string body >|= fun s ->
    print_endline s)
$headers = @{
    "Authorization" = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
}

$params = @{
    entity_type = "task"
    entity_id = "1752587000000097299"
}
$queryString = ($params.GetEnumerator() | ForEach-Object { "$($_.Key)=$([System.Uri]::EscapeDataString($_.Value))" }) -join "&"
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments" + "?" + $queryString

$response = Invoke-RestMethod -Uri $url -Method GET -Headers $headers

$response | ConvertTo-Json
library(httr)

url <- "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments"

params <- list(
  entity_type = "task",
  entity_id = "1752587000000097299"
)

response <- GET(
  url,
  add_headers(Authorization = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"),
  query = params
)

content(response, "text")
import Foundation

var components = URLComponents(string: "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments")!
components.queryItems = [
    URLQueryItem(name: "entity_type", value: "task"),
    URLQueryItem(name: "entity_id", value: "1752587000000097299")
]
let url = components.url!
var request = URLRequest(url: url)
request.httpMethod = "GET"
request.setValue("Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa", forHTTPHeaderField: "Authorization")

let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data, let result = String(data: data, encoding: .utf8) {
        print(result)
    }
    semaphore.signal()
}
task.resume()
semaphore.wait()

Sample Input

entity_type : "task" entity_id : "1752587000000097299"

Sample Response

200{ "attachment" : [ { "attachment_id" : "170876000015530007", "name" : "coder 1.jpg", "type" : "image/jpeg", "size" : "198091", "third_party_file_id" : "muo5y81f02cc9388f4aa3868c5698498cb52d", "entity_id" : "170876000015496423", "entity_type" : "task", "app_domain" : "workdrive", "app_id" : "1", "app_name" : "WorkDrive", "created_by" : "703961433", "created_time" : "1712723408594", "associated_by" : "703961433", "associated_by_name" : "Monica Hemsworth", "associated_time_long" : "1712723410560", "preview_url" : "https://previewengine-accl.zoho.com/thumbnail/WD/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=eyJtb2R1bGUiOiJ0YXNrIiwiZW50aXR5X2lkIjoiMTcwODc2MDAwMDE1NDk2MDIxXzE3MDg3NjAwMDAxNTQ5NjQyMyJ9&size=l", "download_url" : "https://download-accl.zoho.com/v1/workdrive/download/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "permanent_url" : "https://workdrive.zoho.com/file/59cfudc90534a56194e5fbe3802e9e35fa980?authId=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "uploadedZpuid" : "170876000007981001", "trashed" : false }, { "attachment_id" : "170876000015530009", "name" : "coder 2.png", "type" : "image/png", "size" : "700661", "third_party_file_id" : "muo5y7b0436ba9c5e4a17b6833ab53994b239", "entity_id" : "170876000015496423", "entity_type" : "task", "app_domain" : "workdrive", "app_id" : "1", "app_name" : "WorkDrive", "created_by" : "703961433", "created_time" : "1712723408753", "associated_by" : "703961433", "associated_by_name" : "Monica Hemsworth", "associated_time_long" : "1712723410560", "preview_url" : "https://previewengine-accl.zoho.com/thumbnail/WD/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=eyJtb2R1bGUiOiJ0YXNrIiwiZW50aXR5X2lkIjoiMTcwODc2MDAwMDE1NDk2MDIxXzE3MDg3NjAwMDAxNTQ5NjQyMyJ9&size=l", "download_url" : "https://download-accl.zoho.com/v1/workdrive/download/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "permanent_url" : "https://workdrive.zoho.com/file/59cfudc90534a56194e5fbe3802e9e35fa980?authId=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "uploadedZpuid" : "170876000007981001", "trashed" : false }, { "attachment_id" : "170876000015530011", "name" : "coder 3.jpg", "type" : "image/jpeg", "size" : "2482517", "third_party_file_id" : "muo5y87425740d6004b1aa3750138a2e0e7b7", "entity_id" : "170876000015496423", "entity_type" : "task", "app_domain" : "workdrive", "app_id" : "1", "app_name" : "WorkDrive", "created_by" : "703961433", "created_time" : "1712723409130", "associated_by" : "703961433", "associated_by_name" : "Monica Hemsworth", "associated_time_long" : "1712723410560", "preview_url" : "https://previewengine-accl.zoho.com/thumbnail/WD/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=eyJtb2R1bGUiOiJ0YXNrIiwiZW50aXR5X2lkIjoiMTcwODc2MDAwMDE1NDk2MDIxXzE3MDg3NjAwMDAxNTQ5NjQyMyJ9&size=l", "download_url" : "https://download-accl.zoho.com/v1/workdrive/download/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "permanent_url" : "https://workdrive.zoho.com/file/59cfudc90534a56194e5fbe3802e9e35fa980?authId=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "uploadedZpuid" : "170876000007981001", "trashed" : false }, { "attachment_id" : "170876000015530013", "name" : "coder 4.jpg", "type" : "image/jpeg", "size" : "4671262", "third_party_file_id" : "muo5y46d1ca2633e146a98f923157f9d61e62", "entity_id" : "170876000015496423", "entity_type" : "task", "app_domain" : "workdrive", "app_id" : "1", "app_name" : "WorkDrive", "created_by" : "703961433", "created_time" : "1712723409668", "associated_by" : "703961433", "associated_by_name" : "Monica Hemsworth", "associated_time_long" : "1712723410560", "preview_url" : "https://previewengine-accl.zoho.com/thumbnail/WD/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=eyJtb2R1bGUiOiJ0YXNrIiwiZW50aXR5X2lkIjoiMTcwODc2MDAwMDE1NDk2MDIxXzE3MDg3NjAwMDAxNTQ5NjQyMyJ9&size=l", "download_url" : "https://download-accl.zoho.com/v1/workdrive/download/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "permanent_url" : "https://workdrive.zoho.com/file/59cfudc90534a56194e5fbe3802e9e35fa980?authId=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "uploadedZpuid" : "170876000007981001", "trashed" : false }, { "attachment_id" : "170876000015530015", "name" : "coder 5.jpg", "type" : "image/jpeg", "size" : "4741672", "third_party_file_id" : "muo5ya5bb63c567154a90a28cae028addb440", "entity_id" : "170876000015496423", "entity_type" : "task", "app_domain" : "workdrive", "app_id" : "1", "app_name" : "WorkDrive", "created_by" : "703961433", "created_time" : "1712723410250", "associated_by" : "703961433", "associated_by_name" : "Monica Hemsworth", "associated_time_long" : "1712723410560", "preview_url" : "https://previewengine-accl.zoho.com/thumbnail/WD/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=eyJtb2R1bGUiOiJ0YXNrIiwiZW50aXR5X2lkIjoiMTcwODc2MDAwMDE1NDk2MDIxXzE3MDg3NjAwMDAxNTQ5NjQyMyJ9&size=l", "download_url" : "https://download-accl.zoho.com/v1/workdrive/download/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "permanent_url" : "https://workdrive.zoho.com/file/59cfudc90534a56194e5fbe3802e9e35fa980?authId=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "uploadedZpuid" : "170876000007981001", "trashed" : false } ] }

Possible Errors

Get Attachment Details

Get attachments details by attachment id

GET

/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]

OAuth Scope:

ZohoProjects.portals.READ

Path Parameters

Param Name
Data Type
Description

Request Example

Request Example
  • cURL
  • Deluge
  • Node.js
  • Ruby
  • PHP
  • Python
  • C
  • C#
  • C++
  • Clojure
  • Go
  • HTTP
  • Java
  • JS Fetch
  • Kotlin
  • Objective-C
  • OCaml
  • PowerShell
  • R
  • Swift

curl -X GET \
'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]' \
-H 'Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]";
response = invokeUrl
[
    url: url
    type: GET
    connection: "projects"
];
info response;
const https = require('https');
const url = new URL('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]');

const options = {
  hostname: url.hostname,
  path: url.pathname + url.search,
  method: 'GET',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(JSON.parse(data)); });
});

req.on('error', (err) => { console.error(err); });
req.end();
require 'net/http'
require 'uri'
require 'json'

url = URI("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"

response = http.request(request)
puts response.read_body
<?php
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]";

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
import requests

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]"

headers = {
    "Authorization": "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
}

response = requests.get(url, headers=headers)

print(response.json())
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl) {
        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");

        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));

        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
using System.Net.Http;
using System.Text;
using System.Web;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

var request = new HttpRequestMessage(HttpMethod.Get, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]");

var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
    output->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;
        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK)
            std::cout << response << std::endl;
        else
            std::cerr << curl_easy_strerror(res) << std::endl;

        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
(require '[clj-http.client :as client])

(def response
  (client/get "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]"
    {:headers {"Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"}
     :as :json}))

(println (:body response))
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]", nil)
    req.Header.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
GET https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID] HTTP/1.1
Host: https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]
Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();

URIBuilder uriBuilder = new URIBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]");
HttpUriRequest requestObj = new HttpGet(uriBuilder.build());
requestObj.addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

HttpResponse response = httpclient.execute(requestObj);

HttpEntity responseEntity = response.getEntity();
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
const url = 'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]';

const options = {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

fetch(url, options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));
import java.net.HttpURLConnection
import java.net.URL
import okhttp3.HttpUrl.Companion.toHttpUrl

fun main() {
    val url = URL("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]")
    val conn = url.openConnection() as HttpURLConnection
    conn.requestMethod = "GET"
    conn.setRequestProperty("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    val response = conn.inputStream.bufferedReader().readText()
    println(response)
}
NSURL *url = [NSURL URLWithString:@"https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"GET"];
[request setValue:@"Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa" forHTTPHeaderField:@"Authorization"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@", result);
}];
[task resume];
open Lwt
open Cohttp_lwt_unix

let () =
  let uri = Uri.of_string "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]" in
  let headers = Cohttp.Header.init ()
    |> fun h -> Cohttp.Header.add h "Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  in
  Lwt_main.run (
    Client.get ~headers uri >>= fun (_, body) ->
    Cohttp_lwt.Body.to_string body >|= fun s ->
    print_endline s)
$headers = @{
    "Authorization" = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
}

$response = Invoke-RestMethod -Uri "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]" -Method GET -Headers $headers

$response | ConvertTo-Json
library(httr)

url <- "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]"

response <- GET(
  url,
  add_headers(Authorization = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")
)

content(response, "text")
import Foundation

let url = URL(string: "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]")!
var request = URLRequest(url: url)
request.httpMethod = "GET"
request.setValue("Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa", forHTTPHeaderField: "Authorization")

let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data, let result = String(data: data, encoding: .utf8) {
        print(result)
    }
    semaphore.signal()
}
task.resume()
semaphore.wait()

Sample Response

200{ "attachment" : [ { "attachment_id" : "170876000015521051", "name" : "coder.png", "type" : "image/jpeg", "size" : "3973545", "third_party_file_id" : "59cfudc90534a56194e5fbe3802e9e35fa980", "entity_id" : "-1", "app_domain" : "workdrive", "app_id" : "1", "app_name" : "WorkDrive", "created_by" : "703961433", "created_time" : "1712664912090", "associated_time_long" : "-1", "preview_url" : "https://previewengine-accl.zoho.com/thumbnail/WD/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=eyJtb2R1bGUiOiJ0YXNrIiwiZW50aXR5X2lkIjoiMTcwODc2MDAwMDE1NDk2MDIxXzE3MDg3NjAwMDAxNTQ5NjQyMyJ9&size=l", "download_url" : "https://download-accl.zoho.com/v1/workdrive/download/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "permanent_url" : "https://workdrive.zoho.com/file/59cfudc90534a56194e5fbe3802e9e35fa980?authId=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "uploadedZpuid" : "170876000007981001", "trashed" : false } ] }

Possible Errors

Upload Global Attachments

Upload one or more files to the Zoho Projects portal. Use this API to add attachments at the portal level and store them in a specified project folder.

POST

/api/v3/portal/[PORTAL_ID]/attachments

OAuth Scope:

ZohoProjects.portals.CREATE, WorkDrive.workspace.ALL,WorkDrive.files.ALL

Path Parameters

Param Name
Data Type
Description

Query Parameters

Param Name
Data Type
Description

File Parameters

Param Name
Data Type
Description

Request Example

Request Example
  • cURL
  • Deluge
  • Node.js
  • Ruby
  • PHP
  • Python
  • C
  • C#
  • C++
  • Clojure
  • Go
  • HTTP
  • Java
  • JS Fetch
  • JSON
  • Kotlin
  • Objective-C
  • OCaml
  • PowerShell
  • R
  • Swift

curl -X POST \
'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments' \
-H 'Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa' \
--form 'upload_file=@/path/to/file' \
--form-string 'attachment_details={"storage_type":"-","location_details":{"folder_id":"z5ycq2bae5b9867714089b37c16301c202cbf","project_id":"170876000015521678","new_version":"-","file_name":"-","entity_id":"-","entity_type":"-"}}' \
--form-string 'attachments=[{"attachment_id":"-","name":"coder.png","type":"-","size":"-","preview_url":"-","download_url":"-","permanent_url":"-","created_by":"-","created_time":"-","third_party_file_id":"-","app_domain":"-","app_id":"-","version":"-","entity_id":"-","entity_type":"-","associated_by":"-","extra_data":{"set_by_record":"-"}}]' \
--form-string 'document_ids=-'

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments";

fileObj = invokeUrl
[
    url: "/path/to/file"
    type: GET
];

response = invokeUrl
[
    url: url
    type: POST
    files: {"upload_file": fileObj}
    connection: "projects"
];

info response;
const fs = require('fs');
const FormData = require('form-data');
const https = require('https');

const form = new FormData();
form.append('upload_file', fs.createReadStream('/path/to/file'));

const url = new URL('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments');

const options = {
  hostname: url.hostname,
  path: url.pathname,
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa',
    ...form.getHeaders()
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(JSON.parse(data)); });
});

req.on('error', (err) => { console.error(err); });
form.pipe(req);
require 'net/http'
require 'uri'

url = URI("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post::Multipart.new(url, {
  "upload_file" => UploadIO.new(File.new("/path/to/file"), "application/octet-stream")
})
request["Authorization"] = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"

response = http.request(request)
puts response.read_body
<?php

$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments";

$postFields = [
    'upload_file' => new CURLFile('/path/to/file'),
];

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => $postFields,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
import requests

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments"

headers = {
    "Authorization": "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
}

files = {
    "upload_file": open("/path/to/file", "rb")
}

response = requests.post(url, headers=headers, files=files)

print(response.json())
#include <stdio.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl) {
        curl_mime *mime = curl_mime_init(curl);
        curl_mimepart *part = curl_mime_addpart(mime);
        curl_mime_name(part, "upload_file");
        curl_mime_filedata(part, "/path/to/file");

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);

        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));

        curl_mime_free(mime);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
using System.Net.Http;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

var content = new MultipartFormDataContent();
var fileStream = File.OpenRead("/path/to/file");
content.Add(new StreamContent(fileStream), "upload_file", "file");

var request = new HttpRequestMessage(HttpMethod.Post, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments") { Content = content };
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
    output->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;

        curl_mime* mime = curl_mime_init(curl);
        curl_mimepart* part = curl_mime_addpart(mime);
        curl_mime_name(part, "upload_file");
        curl_mime_filedata(part, "/path/to/file");

        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK)
            std::cout << response << std::endl;
        else
            std::cerr << curl_easy_strerror(res) << std::endl;

        curl_mime_free(mime);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
(require '[clj-http.client :as client])
(require '[clojure.java.io :as io])

(def response
  (client/post "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments"
    {:headers {"Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"}
     :multipart [{:name "upload_file"
                  :content (io/file "/path/to/file")}]}))

(println (:body response))
package main

import (
    "bytes"
    "fmt"
    "io"
    "mime/multipart"
    "net/http"
    "os"
)

func main() {
    body := &bytes.Buffer{}
    writer := multipart.NewWriter(body)

    file, _ := os.Open("/path/to/file")
    defer file.Close()
    part, _ := writer.CreateFormFile("upload_file", "file")
    io.Copy(part, file)
    writer.Close()

    req, _ := http.NewRequest("POST", "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments", body)
    req.Header.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")
    req.Header.Add("Content-Type", writer.FormDataContentType())

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    respBody, _ := io.ReadAll(resp.Body)
    fmt.Println(string(respBody))
}
POST https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments HTTP/1.1
Host: https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments
Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa
Content-Type: multipart/form-data; boundary=----FormBoundary

------FormBoundary
Content-Disposition: form-data; name="upload_file"; filename="file"
Content-Type: application/octet-stream

[file content]
------FormBoundary--
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();

HttpEntityEnclosingRequestBase httpRequest = new HttpPost("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments");
httpRequest.addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("upload_file", new File("/path/to/file"), ContentType.DEFAULT_BINARY, "file");
httpRequest.setEntity(builder.build());

HttpResponse response = httpclient.execute(httpRequest);

HttpEntity responseEntity = response.getEntity();
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
const formData = new FormData();
formData.append('upload_file', fileInput.files[0]);

fetch('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  },
  body: formData
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));
{
  "upload_file": "(binary file data)"
}
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import java.io.File

fun main() {
    val client = OkHttpClient()

    val file = File("/path/to/file")
    val body = MultipartBody.Builder()
        .setType(MultipartBody.FORM)
        .addFormDataPart("upload_file", file.name, RequestBody.create(file, "application/octet-stream".toMediaType()))
        .build()

    val request = Request.Builder()
        .url("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments")
        .method("POST", body)
        .addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")
        .build()

    val response = client.newCall(request).execute()
    println(response.body?.string())
}
NSURL *url = [NSURL URLWithString:@"https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa" forHTTPHeaderField:@"Authorization"];

NSString *boundary = [[NSUUID UUID] UUIDString];
[request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary] forHTTPHeaderField:@"Content-Type"];

NSMutableData *body = [NSMutableData data];
NSData *fileData = [NSData dataWithContentsOfFile:@"/path/to/file"];
[body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upload_file\"; filename=\"file\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:fileData];
[body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@", result);
}];
[task resume];
open Lwt
open Cohttp_lwt_unix

let () =
  let uri = Uri.of_string "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments" in
  let file_content = Lwt_io.(with_file ~mode:Input "/path/to/file" read) in
  let boundary = "----FormBoundary" in
  let body_str =
    "--" ^ boundary ^ "\r\n" ^
    "Content-Disposition: form-data; name=\"upload_file\"; filename=\"file\"\r\n" ^
    "Content-Type: application/octet-stream\r\n\r\n" ^
    file_content ^ "\r\n" ^
    "--" ^ boundary ^ "--\r\n" in
  let headers = Cohttp.Header.init ()
    |> fun h -> Cohttp.Header.add h "Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
    |> fun h -> Cohttp.Header.add h "Content-Type" ("multipart/form-data; boundary=" ^ boundary)
  in
  let body = Cohttp_lwt.Body.of_string body_str in
  Lwt_main.run (
    Client.post ~headers ~body uri >>= fun (_, body) ->
    Cohttp_lwt.Body.to_string body >|= fun s ->
    print_endline s)
$headers = @{
    "Authorization" = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
}

$form = @{
    upload_file = Get-Item -Path "/path/to/file"
}

$response = Invoke-RestMethod -Uri "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments" -Method POST -Headers $headers -Form $form

$response | ConvertTo-Json
library(httr)

url <- "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments"

response <- POST(
  url,
  add_headers(Authorization = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"),
  body = list(
    upload_file = upload_file("/path/to/file")
  ),
  encode = "multipart"
)

content(response, "text")
import Foundation

let url = URL(string: "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa", forHTTPHeaderField: "Authorization")

let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")

var body = Data()
let fileData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/file"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"upload_file\"; filename=\"file\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(fileData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body

let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data, let result = String(data: data, encoding: .utf8) {
        print(result)
    }
    semaphore.signal()
}
task.resume()
semaphore.wait()

Sample Input

attachment_details : { "storage_type" : "-", "location_details" : { "folder_id" : "z5ycq2bae5b9867714089b37c16301c202cbf", "project_id" : "170876000015521678", "new_version" : "-", "file_name" : "-", "entity_id" : "-", "entity_type" : "-" } } attachments : [ { "attachment_id" : "-", "name" : "coder.png", "type" : "-", "size" : "-", "preview_url" : "-", "download_url" : "-", "permanent_url" : "-", "created_by" : "-", "created_time" : "-", "third_party_file_id" : "-", "app_domain" : "-", "app_id" : "-", "version" : "-", "entity_id" : "-", "entity_type" : "-", "associated_by" : "-", "extra_data" : { "set_by_record" : "-" } } ] document_ids : -

Sample Response

201{ "attachment" : [ { "attachment_id" : "170876000015521051", "name" : "coder.png", "type" : "image/jpeg", "size" : "3973545", "third_party_file_id" : "59cfudc90534a56194e5fbe3802e9e35fa980", "entity_id" : "-1", "app_domain" : "workdriveUpload", "app_id" : "4", "app_name" : "WorkdriveUpload", "created_by" : "703961433", "created_time" : "1712664912090", "associated_by" : "703961433", "associated_time_long" : "1712664912090", "preview_url" : "https://previewengine-accl.zoho.com/thumbnail/WD/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=eyJtb2R1bGUiOiJ0YXNrIiwiZW50aXR5X2lkIjoiMTcwODc2MDAwMDE1NDk2MDIxXzE3MDg3NjAwMDAxNTQ5NjQyMyJ9&size=l", "download_url" : "https://download-accl.zoho.com/v1/workdrive/download/59cfudc90534a56194e5fbe3802e9e35fa980?x-cli-msg=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "permanent_url" : "https://workdrive.zoho.com/file/59cfudc90534a56194e5fbe3802e9e35fa980?authId=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22170876000015496021_170876000015496423%22%7D", "uploadedZpuid" : "170876000007981001", "trashed" : false } ] }

Possible Errors

Associate Attachment

Associate an uploaded file with a specific module's entity in Zoho Projects.

Maximum File Size: 200 MB Maximum Files per Request: 30 Files

Note: Users can upload files up to 20 MB by default. For larger files, use the upload server and the user must be a member of the selected folder. Files larger than 20 MB must be uploaded using the WorkDrive Large File Upload API.

POST

/api/v3/portal/[PORTAL_ID]/entity-attachments

OAuth Scope:

ZohoProjects.portals.CREATE

Path Parameters

Param Name
Data Type
Description

Body Parameters

Param Name
Data Type
Description

Request Example

Request Example
  • cURL
  • Deluge
  • Node.js
  • Ruby
  • PHP
  • Python
  • C
  • C#
  • C++
  • Clojure
  • Go
  • HTTP
  • Java
  • JS Fetch
  • JSON
  • Kotlin
  • Objective-C
  • OCaml
  • PowerShell
  • R
  • Swift

curl -X POST \
'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments' \
-H 'Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa' \
-H 'Content-Type: application/json' \
-d '{"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]}'

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments";
params = Map();
params.put("entity_type", "task");
params.put("entity_id", "1752587000000097299");
params.put("thirdparty_id", ["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"]);
params.put("attachment_id", ["170876000015530007"]);
response = invokeUrl
[
    url: url
    type: POST
    parameters: params.toString()
    connection: "projects"
];
info response;
const https = require('https');
const url = new URL('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments');

const payload = JSON.stringify({"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]});

const options = {
  hostname: url.hostname,
  path: url.pathname + url.search,
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa',
    'Content-Type': 'application/json',
    'Content-Length': Buffer.byteLength(payload)
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(JSON.parse(data)); });
});

req.on('error', (err) => { console.error(err); });
req.write(payload);
req.end();
require 'net/http'
require 'uri'
require 'json'

url = URI("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
request["Content-Type"] = "application/json"
request.body = '{"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]}'

response = http.request(request)
puts response.read_body
<?php
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments";

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => '{"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]}',
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
import requests

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments"

headers = {
    "Authorization": "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
    "Content-Type": "application/json",
}

payload = '{"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]}'

response = requests.post(url, headers=headers, data=payload)

print(response.json())
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl) {
        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");
        headers = curl_slist_append(headers, "Content-Type: application/json");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"entity_type\":\"task\",\"entity_id\":\"1752587000000097299\",\"thirdparty_id\":[\"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0\"],\"attachment_id\":[\"170876000015530007\"]}");

        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));

        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
using System.Net.Http;
using System.Text;
using System.Web;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

var request = new HttpRequestMessage(HttpMethod.Post, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments");
request.Content = new StringContent(
    @"{""entity_type"":""task"",""entity_id"":""1752587000000097299"",""thirdparty_id"":[""a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0""],""attachment_id"":[""170876000015530007""]}",
    Encoding.UTF8,
    "application/json"
);

var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
    output->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;
        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");
        headers = curl_slist_append(headers, "Content-Type: application/json");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"entity_type\":\"task\",\"entity_id\":\"1752587000000097299\",\"thirdparty_id\":[\"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0\"],\"attachment_id\":[\"170876000015530007\"]}");

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK)
            std::cout << response << std::endl;
        else
            std::cerr << curl_easy_strerror(res) << std::endl;

        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
(require '[clj-http.client :as client])

(def response
  (client/post "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments"
    {:headers {"Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
                "Content-Type" "application/json"}
     :body "{\"entity_type\":\"task\",\"entity_id\":\"1752587000000097299\",\"thirdparty_id\":[\"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0\"],\"attachment_id\":[\"170876000015530007\"]}"
     :as :json}))

(println (:body response))
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    payload := strings.NewReader("{\"entity_type\":\"task\",\"entity_id\":\"1752587000000097299\",\"thirdparty_id\":[\"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0\"],\"attachment_id\":[\"170876000015530007\"]}")
    req, _ := http.NewRequest("POST", "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments", payload)
    req.Header.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")
    req.Header.Add("Content-Type", "application/json")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
POST https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments HTTP/1.1
Host: https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments
Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa
Content-Type: application/json

{"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]}
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();

URIBuilder uriBuilder = new URIBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments");
HttpUriRequest requestObj = new HttpPost(uriBuilder.build());
requestObj.addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

HttpEntityEnclosingRequestBase requestBase = (HttpEntityEnclosingRequestBase) requestObj;
String requestBody = "{\"entity_type\":\"task\",\"entity_id\":\"1752587000000097299\",\"thirdparty_id\":[\"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0\"],\"attachment_id\":[\"170876000015530007\"]}";
requestBase.setEntity(new StringEntity(requestBody, HTTP.UTF_8));

HttpResponse response = httpclient.execute(requestObj);

HttpEntity responseEntity = response.getEntity();
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
const url = 'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments';

const options = {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]})
};

fetch(url, options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));
{"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]}
import java.net.HttpURLConnection
import java.net.URL
import okhttp3.HttpUrl.Companion.toHttpUrl

fun main() {
    val url = URL("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments")
    val conn = url.openConnection() as HttpURLConnection
    conn.requestMethod = "POST"
    conn.setRequestProperty("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")
    conn.setRequestProperty("Content-Type", "application/json")
    conn.doOutput = true
    conn.outputStream.bufferedWriter().use { it.write("""{"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]}""") }

    val response = conn.inputStream.bufferedReader().readText()
    println(response)
}
NSURL *url = [NSURL URLWithString:@"https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa" forHTTPHeaderField:@"Authorization"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSData *body = [@"{\"entity_type\":\"task\",\"entity_id\":\"1752587000000097299\",\"thirdparty_id\":[\"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0\"],\"attachment_id\":[\"170876000015530007\"]}" dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:body];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@", result);
}];
[task resume];
open Lwt
open Cohttp_lwt_unix

let () =
  let uri = Uri.of_string "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments" in
  let headers = Cohttp.Header.init ()
    |> fun h -> Cohttp.Header.add h "Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
    |> fun h -> Cohttp.Header.add h "Content-Type" "application/json"
  in
  let body = Cohttp_lwt.Body.of_string {json|{"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]}|json} in
  Lwt_main.run (
    Client.post ~headers ~body uri >>= fun (_, body) ->
    Cohttp_lwt.Body.to_string body >|= fun s ->
    print_endline s)
$headers = @{
    "Authorization" = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
    "Content-Type" = "application/json"
}

$body = @'
{"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]}
'@

$response = Invoke-RestMethod -Uri "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments" -Method POST -Headers $headers -Body $body

$response | ConvertTo-Json
library(httr)

url <- "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments"

response <- POST(
  url,
  add_headers(Authorization = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"),
  content_type_json(),
  body = "{\"entity_type\":\"task\",\"entity_id\":\"1752587000000097299\",\"thirdparty_id\":[\"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0\"],\"attachment_id\":[\"170876000015530007\"]}"
)

content(response, "text")
import Foundation

let url = URL(string: "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/entity-attachments")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = """
{"entity_type":"task","entity_id":"1752587000000097299","thirdparty_id":["a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"],"attachment_id":["170876000015530007"]}
""".data(using: .utf8)

let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data, let result = String(data: data, encoding: .utf8) {
        print(result)
    }
    semaphore.signal()
}
task.resume()
semaphore.wait()

Sample Input

Content-Type: application/json
{ "entity_type" : "task", "entity_id" : "1752587000000097299", "thirdparty_id" : [ "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0" ], "attachment_id" : [ "170876000015530007" ] }

Sample Response

201{ "attachment" : [ { "attachment_id" : "170876000015530007", "name" : "large_file.zip", "type" : "application/zip", "size" : "52428800", "third_party_file_id" : "muo5y81f02cc9388f4aa3868c5698498cb52d", "entity_id" : "170876000015496423", "entity_type" : "task", "app_domain" : "workdriveUpload", "app_id" : "4", "app_name" : "WorkdriveUpload", "created_by" : "703961433", "created_time" : "1712723408594", "associated_by" : "703961433", "associated_time_long" : "1712723410560", "uploadedZpuid" : "170876000007981001", "trashed" : false } ] }

Possible Errors

Associate attachments

Associate attachments for all entities

POST

/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]

OAuth Scope:

ZohoProjects.portals.CREATE

Path Parameters

Param Name
Data Type
Description

Query Parameters

Param Name
Data Type
Description

Request Example

Request Example
  • cURL
  • Deluge
  • Node.js
  • Ruby
  • PHP
  • Python
  • C
  • C#
  • C++
  • Clojure
  • Go
  • HTTP
  • Java
  • JS Fetch
  • JSON
  • Kotlin
  • Objective-C
  • OCaml
  • PowerShell
  • R
  • Swift

curl -X POST \
'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]' \
-H 'Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa' \
--form-string 'entity_type=task' \
--form-string 'entity_id=1752587000000097299'

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]";
params = Map();
params.put("entity_type", "task");
params.put("entity_id", "1752587000000097299");
response = invokeUrl
[
    url: url
    type: POST
    parameters: params
    connection: "projects"
];
info response;
const https = require('https');
const url = new URL('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]');
url.searchParams.append('entity_type', 'task');
url.searchParams.append('entity_id', '1752587000000097299');

const options = {
  hostname: url.hostname,
  path: url.pathname + url.search,
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(JSON.parse(data)); });
});

req.on('error', (err) => { console.error(err); });
req.end();
require 'net/http'
require 'uri'
require 'json'

url = URI("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]")
params = {
  "entity_type" => "task",
  "entity_id" => "1752587000000097299"
}
url.query = URI.encode_www_form(params)

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"

response = http.request(request)
puts response.read_body
<?php
$params = [
    'entity_type' => 'task',
    'entity_id' => '1752587000000097299',
];
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]" . "?" . http_build_query($params);

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
import requests

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]"

params = {
    "entity_type": "task",
    "entity_id": "1752587000000097299"
}

headers = {
    "Authorization": "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
}

response = requests.post(url, headers=headers, params=params)

print(response.json())
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl) {
        char *enc_entity_type = curl_easy_escape(curl, "task", 0);
        char *enc_entity_id = curl_easy_escape(curl, "1752587000000097299", 0);
        char url[2048];
        snprintf(url, sizeof(url), "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]?entity_type=%s&entity_id=%s", enc_entity_type, enc_entity_id);

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");

        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));

        curl_free(enc_entity_type);
        curl_free(enc_entity_id);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
using System.Net.Http;
using System.Text;
using System.Web;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

var query = HttpUtility.ParseQueryString(string.Empty);
query["entity_type"] = "task";
query["entity_id"] = "1752587000000097299";
var uriBuilder = new UriBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]") { Query = query.ToString() };
var request = new HttpRequestMessage(HttpMethod.Post, uriBuilder.Uri);

var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
    output->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;
        char* enc_entity_type = curl_easy_escape(curl, "task", 0);
        char* enc_entity_id = curl_easy_escape(curl, "1752587000000097299", 0);
        std::string url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]";
        url += "?entity_type=" + std::string(enc_entity_type);
        url += "&entity_id=" + std::string(enc_entity_id);

        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK)
            std::cout << response << std::endl;
        else
            std::cerr << curl_easy_strerror(res) << std::endl;

        curl_free(enc_entity_type);
        curl_free(enc_entity_id);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
(require '[clj-http.client :as client])

(let [enc-entity_type (java.net.URLEncoder/encode "task" "UTF-8")
      enc-entity_id (java.net.URLEncoder/encode "1752587000000097299" "UTF-8")
      url (str "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]" "?entity_type=" enc-entity_type "&entity_id=" enc-entity_id)]
(def response
  (client/post url
    {:headers {"Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"}
     :as :json}))

(println (:body response))
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
)

func main() {
    req, _ := http.NewRequest("POST", "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]", nil)
    q := req.URL.Query()
    q.Add("entity_type", "task")
    q.Add("entity_id", "1752587000000097299")
    req.URL.RawQuery = q.Encode()
    req.Header.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
POST https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]?entity_type=task&entity_id=1752587000000097299 HTTP/1.1
Host: https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]?entity_type=task&entity_id=1752587000000097299
Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();

URIBuilder uriBuilder = new URIBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]");
uriBuilder.addParameter("entity_type", "task");
uriBuilder.addParameter("entity_id", "1752587000000097299");
HttpUriRequest requestObj = new HttpPost(uriBuilder.build());
requestObj.addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

HttpResponse response = httpclient.execute(requestObj);

HttpEntity responseEntity = response.getEntity();
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
const url = 'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]';

const params = new URLSearchParams({
  'entity_type': 'task',
  'entity_id': '1752587000000097299'
});

const options = {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

fetch(url + '?' + params.toString(), options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));
entity_type = "task"
entity_id = "1752587000000097299"
import java.net.HttpURLConnection
import java.net.URL
import okhttp3.HttpUrl.Companion.toHttpUrl

fun main() {
    val urlBuilder = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]".toHttpUrl().newBuilder()
    urlBuilder.addQueryParameter("entity_type", "task")
    urlBuilder.addQueryParameter("entity_id", "1752587000000097299")
    val url = URL(urlBuilder.build().toString())
    val conn = url.openConnection() as HttpURLConnection
    conn.requestMethod = "POST"
    conn.setRequestProperty("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    val response = conn.inputStream.bufferedReader().readText()
    println(response)
}
NSString *encodedEntity_type = [@"task" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *encodedEntity_id = [@"1752587000000097299" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *urlString = [NSString stringWithFormat:@"https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]?entity_type=%@&entity_id=%@", encodedEntity_type, encodedEntity_id];
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa" forHTTPHeaderField:@"Authorization"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@", result);
}];
[task resume];
open Lwt
open Cohttp_lwt_unix

let () =
  let enc_entity_type = Uri.pct_encode "task" in
  let enc_entity_id = Uri.pct_encode "1752587000000097299" in
  let uri = Uri.of_string ("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]" ^ "?entity_type=" ^ enc_entity_type ^ "&entity_id=" ^ enc_entity_id) in
  let headers = Cohttp.Header.init ()
    |> fun h -> Cohttp.Header.add h "Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  in
  Lwt_main.run (
    Client.post ~headers uri >>= fun (_, body) ->
    Cohttp_lwt.Body.to_string body >|= fun s ->
    print_endline s)
$headers = @{
    "Authorization" = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
}

$params = @{
    entity_type = "task"
    entity_id = "1752587000000097299"
}
$queryString = ($params.GetEnumerator() | ForEach-Object { "$($_.Key)=$([System.Uri]::EscapeDataString($_.Value))" }) -join "&"
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]" + "?" + $queryString

$response = Invoke-RestMethod -Uri $url -Method POST -Headers $headers

$response | ConvertTo-Json
library(httr)

url <- "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]"

params <- list(
  entity_type = "task",
  entity_id = "1752587000000097299"
)

response <- POST(
  url,
  add_headers(Authorization = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"),
  query = params
)

content(response, "text")
import Foundation

var components = URLComponents(string: "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]")!
components.queryItems = [
    URLQueryItem(name: "entity_type", value: "task"),
    URLQueryItem(name: "entity_id", value: "1752587000000097299")
]
let url = components.url!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa", forHTTPHeaderField: "Authorization")

let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data, let result = String(data: data, encoding: .utf8) {
        print(result)
    }
    semaphore.signal()
}
task.resume()
semaphore.wait()

Sample Input

entity_type : "task" entity_id : "1752587000000097299"

Sample Response

200

Possible Errors

Disassociate Attachment

Disassociate for all entities

DELETE

/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]

OAuth Scope:

ZohoProjects.portals.DELETE, WorkDrive.workspace.ALL,WorkDrive.files.ALL

Path Parameters

Param Name
Data Type
Description

Query Parameters

Param Name
Data Type
Description

Request Example

Request Example
  • cURL
  • Deluge
  • Node.js
  • Ruby
  • PHP
  • Python
  • C
  • C#
  • C++
  • Clojure
  • Go
  • HTTP
  • Java
  • JS Fetch
  • JSON
  • Kotlin
  • Objective-C
  • OCaml
  • PowerShell
  • R
  • Swift

curl -X DELETE \
'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]?entity_type=task&entity_id=1752587000000097299' \
-H 'Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]";
params = Map();
params.put("entity_type", "task");
params.put("entity_id", "1752587000000097299");
response = invokeUrl
[
    url: url
    type: DELETE
    parameters: params
    connection: "projects"
];
info response;
const https = require('https');
const url = new URL('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]');
url.searchParams.append('entity_type', 'task');
url.searchParams.append('entity_id', '1752587000000097299');

const options = {
  hostname: url.hostname,
  path: url.pathname + url.search,
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(JSON.parse(data)); });
});

req.on('error', (err) => { console.error(err); });
req.end();
require 'net/http'
require 'uri'
require 'json'

url = URI("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]")
params = {
  "entity_type" => "task",
  "entity_id" => "1752587000000097299"
}
url.query = URI.encode_www_form(params)

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Authorization"] = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"

response = http.request(request)
puts response.read_body
<?php
$params = [
    'entity_type' => 'task',
    'entity_id' => '1752587000000097299',
];
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]" . "?" . http_build_query($params);

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
import requests

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]"

params = {
    "entity_type": "task",
    "entity_id": "1752587000000097299"
}

headers = {
    "Authorization": "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
}

response = requests.delete(url, headers=headers, params=params)

print(response.json())
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl) {
        char *enc_entity_type = curl_easy_escape(curl, "task", 0);
        char *enc_entity_id = curl_easy_escape(curl, "1752587000000097299", 0);
        char url[2048];
        snprintf(url, sizeof(url), "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]?entity_type=%s&entity_id=%s", enc_entity_type, enc_entity_id);

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");

        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));

        curl_free(enc_entity_type);
        curl_free(enc_entity_id);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
using System.Net.Http;
using System.Text;
using System.Web;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

var query = HttpUtility.ParseQueryString(string.Empty);
query["entity_type"] = "task";
query["entity_id"] = "1752587000000097299";
var uriBuilder = new UriBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]") { Query = query.ToString() };
var request = new HttpRequestMessage(HttpMethod.Delete, uriBuilder.Uri);

var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
    output->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;
        char* enc_entity_type = curl_easy_escape(curl, "task", 0);
        char* enc_entity_id = curl_easy_escape(curl, "1752587000000097299", 0);
        std::string url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]";
        url += "?entity_type=" + std::string(enc_entity_type);
        url += "&entity_id=" + std::string(enc_entity_id);

        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK)
            std::cout << response << std::endl;
        else
            std::cerr << curl_easy_strerror(res) << std::endl;

        curl_free(enc_entity_type);
        curl_free(enc_entity_id);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
(require '[clj-http.client :as client])

(let [enc-entity_type (java.net.URLEncoder/encode "task" "UTF-8")
      enc-entity_id (java.net.URLEncoder/encode "1752587000000097299" "UTF-8")
      url (str "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]" "?entity_type=" enc-entity_type "&entity_id=" enc-entity_id)]
(def response
  (client/delete url
    {:headers {"Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"}
     :as :json}))

(println (:body response))
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
)

func main() {
    req, _ := http.NewRequest("DELETE", "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]", nil)
    q := req.URL.Query()
    q.Add("entity_type", "task")
    q.Add("entity_id", "1752587000000097299")
    req.URL.RawQuery = q.Encode()
    req.Header.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
DELETE https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]?entity_type=task&entity_id=1752587000000097299 HTTP/1.1
Host: https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]?entity_type=task&entity_id=1752587000000097299
Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();

URIBuilder uriBuilder = new URIBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]");
uriBuilder.addParameter("entity_type", "task");
uriBuilder.addParameter("entity_id", "1752587000000097299");
HttpUriRequest requestObj = new HttpDelete(uriBuilder.build());
requestObj.addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

HttpResponse response = httpclient.execute(requestObj);

HttpEntity responseEntity = response.getEntity();
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
const url = 'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]';

const params = new URLSearchParams({
  'entity_type': 'task',
  'entity_id': '1752587000000097299'
});

const options = {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

fetch(url + '?' + params.toString(), options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));
entity_type = "task"
entity_id = "1752587000000097299"
import java.net.HttpURLConnection
import java.net.URL
import okhttp3.HttpUrl.Companion.toHttpUrl

fun main() {
    val urlBuilder = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]".toHttpUrl().newBuilder()
    urlBuilder.addQueryParameter("entity_type", "task")
    urlBuilder.addQueryParameter("entity_id", "1752587000000097299")
    val url = URL(urlBuilder.build().toString())
    val conn = url.openConnection() as HttpURLConnection
    conn.requestMethod = "DELETE"
    conn.setRequestProperty("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    val response = conn.inputStream.bufferedReader().readText()
    println(response)
}
NSString *encodedEntity_type = [@"task" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *encodedEntity_id = [@"1752587000000097299" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *urlString = [NSString stringWithFormat:@"https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]?entity_type=%@&entity_id=%@", encodedEntity_type, encodedEntity_id];
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"DELETE"];
[request setValue:@"Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa" forHTTPHeaderField:@"Authorization"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@", result);
}];
[task resume];
open Lwt
open Cohttp_lwt_unix

let () =
  let enc_entity_type = Uri.pct_encode "task" in
  let enc_entity_id = Uri.pct_encode "1752587000000097299" in
  let uri = Uri.of_string ("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]" ^ "?entity_type=" ^ enc_entity_type ^ "&entity_id=" ^ enc_entity_id) in
  let headers = Cohttp.Header.init ()
    |> fun h -> Cohttp.Header.add h "Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  in
  Lwt_main.run (
    Client.delete ~headers uri >>= fun (_, body) ->
    Cohttp_lwt.Body.to_string body >|= fun s ->
    print_endline s)
$headers = @{
    "Authorization" = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
}

$params = @{
    entity_type = "task"
    entity_id = "1752587000000097299"
}
$queryString = ($params.GetEnumerator() | ForEach-Object { "$($_.Key)=$([System.Uri]::EscapeDataString($_.Value))" }) -join "&"
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]" + "?" + $queryString

$response = Invoke-RestMethod -Uri $url -Method DELETE -Headers $headers

$response | ConvertTo-Json
library(httr)

url <- "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]"

params <- list(
  entity_type = "task",
  entity_id = "1752587000000097299"
)

response <- DELETE(
  url,
  add_headers(Authorization = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"),
  query = params
)

content(response, "text")
import Foundation

var components = URLComponents(string: "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/projects/[PROJECT_ID]/attachments/[ATTACHMENT_ID]")!
components.queryItems = [
    URLQueryItem(name: "entity_type", value: "task"),
    URLQueryItem(name: "entity_id", value: "1752587000000097299")
]
let url = components.url!
var request = URLRequest(url: url)
request.httpMethod = "DELETE"
request.setValue("Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa", forHTTPHeaderField: "Authorization")

let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data, let result = String(data: data, encoding: .utf8) {
        print(result)
    }
    semaphore.signal()
}
task.resume()
semaphore.wait()

Sample Input

entity_type : "task" entity_id : "1752587000000097299"

Sample Response

204 No Content

Possible Errors

Attach Files

Upload one or more files and associate them with a record (entity) in the Zoho Projects portal.

POST

/api/v3/portal/[PORTAL_ID]/associate-attachments

OAuth Scope:

ZohoProjects.portals.CREATE, WorkDrive.workspace.ALL,WorkDrive.files.ALL

Path Parameters

Param Name
Data Type
Description

Query Parameters

Param Name
Data Type
Description

File Parameters

Param Name
Data Type
Description

Request Example

Request Example
  • cURL
  • Deluge
  • Node.js
  • Ruby
  • PHP
  • Python
  • C
  • C#
  • C++
  • Clojure
  • Go
  • HTTP
  • Java
  • JS Fetch
  • JSON
  • Kotlin
  • Objective-C
  • OCaml
  • PowerShell
  • R
  • Swift

curl -X POST \
'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments' \
-H 'Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa' \
--form 'upload_file=@/path/to/file' \
--form-string 'entity_type=task' \
--form-string 'entity_id=1752587000000097299' \
--form-string 'folder_id=170876000015521124'

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments";

fileObj = invokeUrl
[
    url: "/path/to/file"
    type: GET
];

response = invokeUrl
[
    url: url
    type: POST
    files: {"upload_file": fileObj}
    connection: "projects"
];

info response;
const fs = require('fs');
const FormData = require('form-data');
const https = require('https');

const form = new FormData();
form.append('upload_file', fs.createReadStream('/path/to/file'));

const url = new URL('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments');

const options = {
  hostname: url.hostname,
  path: url.pathname,
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa',
    ...form.getHeaders()
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(JSON.parse(data)); });
});

req.on('error', (err) => { console.error(err); });
form.pipe(req);
require 'net/http'
require 'uri'

url = URI("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post::Multipart.new(url, {
  "upload_file" => UploadIO.new(File.new("/path/to/file"), "application/octet-stream")
})
request["Authorization"] = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"

response = http.request(request)
puts response.read_body
<?php

$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments";

$postFields = [
    'upload_file' => new CURLFile('/path/to/file'),
];

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => $postFields,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
import requests

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments"

headers = {
    "Authorization": "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
}

files = {
    "upload_file": open("/path/to/file", "rb")
}

response = requests.post(url, headers=headers, files=files)

print(response.json())
#include <stdio.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl) {
        curl_mime *mime = curl_mime_init(curl);
        curl_mimepart *part = curl_mime_addpart(mime);
        curl_mime_name(part, "upload_file");
        curl_mime_filedata(part, "/path/to/file");

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);

        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));

        curl_mime_free(mime);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
using System.Net.Http;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

var content = new MultipartFormDataContent();
var fileStream = File.OpenRead("/path/to/file");
content.Add(new StreamContent(fileStream), "upload_file", "file");

var request = new HttpRequestMessage(HttpMethod.Post, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments") { Content = content };
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
    output->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;

        curl_mime* mime = curl_mime_init(curl);
        curl_mimepart* part = curl_mime_addpart(mime);
        curl_mime_name(part, "upload_file");
        curl_mime_filedata(part, "/path/to/file");

        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK)
            std::cout << response << std::endl;
        else
            std::cerr << curl_easy_strerror(res) << std::endl;

        curl_mime_free(mime);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
(require '[clj-http.client :as client])
(require '[clojure.java.io :as io])

(def response
  (client/post "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments"
    {:headers {"Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"}
     :multipart [{:name "upload_file"
                  :content (io/file "/path/to/file")}]}))

(println (:body response))
package main

import (
    "bytes"
    "fmt"
    "io"
    "mime/multipart"
    "net/http"
    "os"
)

func main() {
    body := &bytes.Buffer{}
    writer := multipart.NewWriter(body)

    file, _ := os.Open("/path/to/file")
    defer file.Close()
    part, _ := writer.CreateFormFile("upload_file", "file")
    io.Copy(part, file)
    writer.Close()

    req, _ := http.NewRequest("POST", "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments", body)
    req.Header.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")
    req.Header.Add("Content-Type", writer.FormDataContentType())

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    respBody, _ := io.ReadAll(resp.Body)
    fmt.Println(string(respBody))
}
POST https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments HTTP/1.1
Host: https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments
Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa
Content-Type: multipart/form-data; boundary=----FormBoundary

------FormBoundary
Content-Disposition: form-data; name="upload_file"; filename="file"
Content-Type: application/octet-stream

[file content]
------FormBoundary--
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();

HttpEntityEnclosingRequestBase httpRequest = new HttpPost("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments");
httpRequest.addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("upload_file", new File("/path/to/file"), ContentType.DEFAULT_BINARY, "file");
httpRequest.setEntity(builder.build());

HttpResponse response = httpclient.execute(httpRequest);

HttpEntity responseEntity = response.getEntity();
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
const formData = new FormData();
formData.append('upload_file', fileInput.files[0]);

fetch('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  },
  body: formData
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));
{
  "upload_file": "(binary file data)"
}
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import java.io.File

fun main() {
    val client = OkHttpClient()

    val file = File("/path/to/file")
    val body = MultipartBody.Builder()
        .setType(MultipartBody.FORM)
        .addFormDataPart("upload_file", file.name, RequestBody.create(file, "application/octet-stream".toMediaType()))
        .build()

    val request = Request.Builder()
        .url("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments")
        .method("POST", body)
        .addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")
        .build()

    val response = client.newCall(request).execute()
    println(response.body?.string())
}
NSURL *url = [NSURL URLWithString:@"https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa" forHTTPHeaderField:@"Authorization"];

NSString *boundary = [[NSUUID UUID] UUIDString];
[request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary] forHTTPHeaderField:@"Content-Type"];

NSMutableData *body = [NSMutableData data];
NSData *fileData = [NSData dataWithContentsOfFile:@"/path/to/file"];
[body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upload_file\"; filename=\"file\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:fileData];
[body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@", result);
}];
[task resume];
open Lwt
open Cohttp_lwt_unix

let () =
  let uri = Uri.of_string "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments" in
  let file_content = Lwt_io.(with_file ~mode:Input "/path/to/file" read) in
  let boundary = "----FormBoundary" in
  let body_str =
    "--" ^ boundary ^ "\r\n" ^
    "Content-Disposition: form-data; name=\"upload_file\"; filename=\"file\"\r\n" ^
    "Content-Type: application/octet-stream\r\n\r\n" ^
    file_content ^ "\r\n" ^
    "--" ^ boundary ^ "--\r\n" in
  let headers = Cohttp.Header.init ()
    |> fun h -> Cohttp.Header.add h "Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
    |> fun h -> Cohttp.Header.add h "Content-Type" ("multipart/form-data; boundary=" ^ boundary)
  in
  let body = Cohttp_lwt.Body.of_string body_str in
  Lwt_main.run (
    Client.post ~headers ~body uri >>= fun (_, body) ->
    Cohttp_lwt.Body.to_string body >|= fun s ->
    print_endline s)
$headers = @{
    "Authorization" = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
}

$form = @{
    upload_file = Get-Item -Path "/path/to/file"
}

$response = Invoke-RestMethod -Uri "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments" -Method POST -Headers $headers -Form $form

$response | ConvertTo-Json
library(httr)

url <- "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments"

response <- POST(
  url,
  add_headers(Authorization = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"),
  body = list(
    upload_file = upload_file("/path/to/file")
  ),
  encode = "multipart"
)

content(response, "text")
import Foundation

let url = URL(string: "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/associate-attachments")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa", forHTTPHeaderField: "Authorization")

let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")

var body = Data()
let fileData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/file"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"upload_file\"; filename=\"file\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(fileData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body

let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data, let result = String(data: data, encoding: .utf8) {
        print(result)
    }
    semaphore.signal()
}
task.resume()
semaphore.wait()

Sample Input

entity_type : "task" entity_id : "1752587000000097299" folder_id : "170876000015521124"

Sample Response

201{ "attachment" : [ { "id" : "269068000000182029", "name" : "elephant 10-03-2026 19:27:56:265.jpeg", "type" : "image/jpeg", "size" : "8006", "created_by" : { "zpuid" : "269068000000122003", "name" : "Leon Drummond", "last_name" : "Drummond", "first_name" : "Leon", "email" : "leon.drummond@zylker.com", "zuid" : "119400224" }, "created_time" : "2026-03-10T13:57:56.572Z", "associated_time_long" : "2026-03-10T13:57:56.591Z", "permanent_url" : "https://workdrive.zoho.com/file/3yohu4929bb99551042ce9f351b14bf531a18?authId=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22269068000000169003_269068000000169169%22%7D", "download_url" : "https://download.zoho.com/v1/workdrive/download/3yohu4929bb99551042ce9f351b14bf531a18?x-cli-msg=%7B%22module%22%3A%22task%22%2C%22entity_id%22%3A%22269068000000169003_269068000000169169%22%7D" } ] }

Possible Errors

Associate Multiple attachments

Associate Multiple attachments for all entities

POST

/api/v3/portal/[PORTAL_ID]/attachments/associate

OAuth Scope:

ZohoProjects.portals.CREATE

Path Parameters

Param Name
Data Type
Description

Query Parameters

Param Name
Data Type
Description

Request Example

Request Example
  • cURL
  • Deluge
  • Node.js
  • Ruby
  • PHP
  • Python
  • C
  • C#
  • C++
  • Clojure
  • Go
  • HTTP
  • Java
  • JS Fetch
  • JSON
  • Kotlin
  • Objective-C
  • OCaml
  • PowerShell
  • R
  • Swift

curl -X POST \
'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate' \
-H 'Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa' \
--form-string 'attachment_ids=[12345678987654321]' \
--form-string 'entity_type=task' \
--form-string 'entity_id=1752587000000097299' \
--form-string 'project_id=23806000097545166'

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate";
params = Map();
params.put("attachment_ids", "[12345678987654321]");
params.put("entity_type", "task");
params.put("entity_id", "1752587000000097299");
params.put("project_id", "23806000097545166");
response = invokeUrl
[
    url: url
    type: POST
    parameters: params
    connection: "projects"
];
info response;
const https = require('https');
const url = new URL('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate');
url.searchParams.append('attachment_ids', '[12345678987654321]');
url.searchParams.append('entity_type', 'task');
url.searchParams.append('entity_id', '1752587000000097299');
url.searchParams.append('project_id', '23806000097545166');

const options = {
  hostname: url.hostname,
  path: url.pathname + url.search,
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(JSON.parse(data)); });
});

req.on('error', (err) => { console.error(err); });
req.end();
require 'net/http'
require 'uri'
require 'json'

url = URI("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate")
params = {
  "attachment_ids" => "[12345678987654321]",
  "entity_type" => "task",
  "entity_id" => "1752587000000097299",
  "project_id" => "23806000097545166"
}
url.query = URI.encode_www_form(params)

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"

response = http.request(request)
puts response.read_body
<?php
$params = [
    'attachment_ids' => '[12345678987654321]',
    'entity_type' => 'task',
    'entity_id' => '1752587000000097299',
    'project_id' => '23806000097545166',
];
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate" . "?" . http_build_query($params);

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
import requests

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate"

params = {
    "attachment_ids": "[12345678987654321]",
    "entity_type": "task",
    "entity_id": "1752587000000097299",
    "project_id": "23806000097545166"
}

headers = {
    "Authorization": "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
}

response = requests.post(url, headers=headers, params=params)

print(response.json())
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl) {
        char *enc_attachment_ids = curl_easy_escape(curl, "[12345678987654321]", 0);
        char *enc_entity_type = curl_easy_escape(curl, "task", 0);
        char *enc_entity_id = curl_easy_escape(curl, "1752587000000097299", 0);
        char *enc_project_id = curl_easy_escape(curl, "23806000097545166", 0);
        char url[2048];
        snprintf(url, sizeof(url), "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate?attachment_ids=%s&entity_type=%s&entity_id=%s&project_id=%s", enc_attachment_ids, enc_entity_type, enc_entity_id, enc_project_id);

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");

        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));

        curl_free(enc_attachment_ids);
        curl_free(enc_entity_type);
        curl_free(enc_entity_id);
        curl_free(enc_project_id);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
using System.Net.Http;
using System.Text;
using System.Web;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

var query = HttpUtility.ParseQueryString(string.Empty);
query["attachment_ids"] = "[12345678987654321]";
query["entity_type"] = "task";
query["entity_id"] = "1752587000000097299";
query["project_id"] = "23806000097545166";
var uriBuilder = new UriBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate") { Query = query.ToString() };
var request = new HttpRequestMessage(HttpMethod.Post, uriBuilder.Uri);

var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
    output->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;
        char* enc_attachment_ids = curl_easy_escape(curl, "[12345678987654321]", 0);
        char* enc_entity_type = curl_easy_escape(curl, "task", 0);
        char* enc_entity_id = curl_easy_escape(curl, "1752587000000097299", 0);
        char* enc_project_id = curl_easy_escape(curl, "23806000097545166", 0);
        std::string url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate";
        url += "?attachment_ids=" + std::string(enc_attachment_ids);
        url += "&entity_type=" + std::string(enc_entity_type);
        url += "&entity_id=" + std::string(enc_entity_id);
        url += "&project_id=" + std::string(enc_project_id);

        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK)
            std::cout << response << std::endl;
        else
            std::cerr << curl_easy_strerror(res) << std::endl;

        curl_free(enc_attachment_ids);
        curl_free(enc_entity_type);
        curl_free(enc_entity_id);
        curl_free(enc_project_id);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
(require '[clj-http.client :as client])

(let [enc-attachment_ids (java.net.URLEncoder/encode "[12345678987654321]" "UTF-8")
      enc-entity_type (java.net.URLEncoder/encode "task" "UTF-8")
      enc-entity_id (java.net.URLEncoder/encode "1752587000000097299" "UTF-8")
      enc-project_id (java.net.URLEncoder/encode "23806000097545166" "UTF-8")
      url (str "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate" "?attachment_ids=" enc-attachment_ids "&entity_type=" enc-entity_type "&entity_id=" enc-entity_id "&project_id=" enc-project_id)]
(def response
  (client/post url
    {:headers {"Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"}
     :as :json}))

(println (:body response))
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
)

func main() {
    req, _ := http.NewRequest("POST", "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate", nil)
    q := req.URL.Query()
    q.Add("attachment_ids", "[12345678987654321]")
    q.Add("entity_type", "task")
    q.Add("entity_id", "1752587000000097299")
    q.Add("project_id", "23806000097545166")
    req.URL.RawQuery = q.Encode()
    req.Header.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
POST https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate?attachment_ids=%5B12345678987654321%5D&entity_type=task&entity_id=1752587000000097299&project_id=23806000097545166 HTTP/1.1
Host: https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate?attachment_ids=%5B12345678987654321%5D&entity_type=task&entity_id=1752587000000097299&project_id=23806000097545166
Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();

URIBuilder uriBuilder = new URIBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate");
uriBuilder.addParameter("attachment_ids", "[12345678987654321]");
uriBuilder.addParameter("entity_type", "task");
uriBuilder.addParameter("entity_id", "1752587000000097299");
uriBuilder.addParameter("project_id", "23806000097545166");
HttpUriRequest requestObj = new HttpPost(uriBuilder.build());
requestObj.addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

HttpResponse response = httpclient.execute(requestObj);

HttpEntity responseEntity = response.getEntity();
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
const url = 'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate';

const params = new URLSearchParams({
  'attachment_ids': '[12345678987654321]',
  'entity_type': 'task',
  'entity_id': '1752587000000097299',
  'project_id': '23806000097545166'
});

const options = {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

fetch(url + '?' + params.toString(), options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));
attachment_ids = "[12345678987654321]"
entity_type = "task"
entity_id = "1752587000000097299"
project_id = "23806000097545166"
import java.net.HttpURLConnection
import java.net.URL
import okhttp3.HttpUrl.Companion.toHttpUrl

fun main() {
    val urlBuilder = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate".toHttpUrl().newBuilder()
    urlBuilder.addQueryParameter("attachment_ids", "[12345678987654321]")
    urlBuilder.addQueryParameter("entity_type", "task")
    urlBuilder.addQueryParameter("entity_id", "1752587000000097299")
    urlBuilder.addQueryParameter("project_id", "23806000097545166")
    val url = URL(urlBuilder.build().toString())
    val conn = url.openConnection() as HttpURLConnection
    conn.requestMethod = "POST"
    conn.setRequestProperty("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    val response = conn.inputStream.bufferedReader().readText()
    println(response)
}
NSString *encodedAttachment_ids = [@"[12345678987654321]" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *encodedEntity_type = [@"task" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *encodedEntity_id = [@"1752587000000097299" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *encodedProject_id = [@"23806000097545166" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *urlString = [NSString stringWithFormat:@"https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate?attachment_ids=%@&entity_type=%@&entity_id=%@&project_id=%@", encodedAttachment_ids, encodedEntity_type, encodedEntity_id, encodedProject_id];
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa" forHTTPHeaderField:@"Authorization"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@", result);
}];
[task resume];
open Lwt
open Cohttp_lwt_unix

let () =
  let enc_attachment_ids = Uri.pct_encode "[12345678987654321]" in
  let enc_entity_type = Uri.pct_encode "task" in
  let enc_entity_id = Uri.pct_encode "1752587000000097299" in
  let enc_project_id = Uri.pct_encode "23806000097545166" in
  let uri = Uri.of_string ("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate" ^ "?attachment_ids=" ^ enc_attachment_ids ^ "&entity_type=" ^ enc_entity_type ^ "&entity_id=" ^ enc_entity_id ^ "&project_id=" ^ enc_project_id) in
  let headers = Cohttp.Header.init ()
    |> fun h -> Cohttp.Header.add h "Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  in
  Lwt_main.run (
    Client.post ~headers uri >>= fun (_, body) ->
    Cohttp_lwt.Body.to_string body >|= fun s ->
    print_endline s)
$headers = @{
    "Authorization" = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
}

$params = @{
    attachment_ids = "[12345678987654321]"
    entity_type = "task"
    entity_id = "1752587000000097299"
    project_id = "23806000097545166"
}
$queryString = ($params.GetEnumerator() | ForEach-Object { "$($_.Key)=$([System.Uri]::EscapeDataString($_.Value))" }) -join "&"
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate" + "?" + $queryString

$response = Invoke-RestMethod -Uri $url -Method POST -Headers $headers

$response | ConvertTo-Json
library(httr)

url <- "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate"

params <- list(
  attachment_ids = "[12345678987654321]",
  entity_type = "task",
  entity_id = "1752587000000097299",
  project_id = "23806000097545166"
)

response <- POST(
  url,
  add_headers(Authorization = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"),
  query = params
)

content(response, "text")
import Foundation

var components = URLComponents(string: "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/associate")!
components.queryItems = [
    URLQueryItem(name: "attachment_ids", value: "[12345678987654321]"),
    URLQueryItem(name: "entity_type", value: "task"),
    URLQueryItem(name: "entity_id", value: "1752587000000097299"),
    URLQueryItem(name: "project_id", value: "23806000097545166")
]
let url = components.url!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa", forHTTPHeaderField: "Authorization")

let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data, let result = String(data: data, encoding: .utf8) {
        print(result)
    }
    semaphore.signal()
}
task.resume()
semaphore.wait()

Sample Input

attachment_ids : "[12345678987654321]" entity_type : "task" entity_id : "1752587000000097299" project_id : "23806000097545166"

Sample Response

200

Disassociate Multiple attachments

Disassociate Multiple attachments for all entities

DELETE

/api/v3/portal/[PORTAL_ID]/attachments/disassociate

OAuth Scope:

ZohoProjects.portals.DELETE

Path Parameters

Param Name
Data Type
Description

Query Parameters

Param Name
Data Type
Description

Request Example

Request Example
  • cURL
  • Deluge
  • Node.js
  • Ruby
  • PHP
  • Python
  • C
  • C#
  • C++
  • Clojure
  • Go
  • HTTP
  • Java
  • JS Fetch
  • JSON
  • Kotlin
  • Objective-C
  • OCaml
  • PowerShell
  • R
  • Swift

curl -X DELETE \
'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate?attachment_ids=%5B12345678987654321%5D&entity_type=task&entity_id=1752587000000097299&project_id=23806000097545166' \
-H 'Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate";
params = Map();
params.put("attachment_ids", "[12345678987654321]");
params.put("entity_type", "task");
params.put("entity_id", "1752587000000097299");
params.put("project_id", "23806000097545166");
response = invokeUrl
[
    url: url
    type: DELETE
    parameters: params
    connection: "projects"
];
info response;
const https = require('https');
const url = new URL('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate');
url.searchParams.append('attachment_ids', '[12345678987654321]');
url.searchParams.append('entity_type', 'task');
url.searchParams.append('entity_id', '1752587000000097299');
url.searchParams.append('project_id', '23806000097545166');

const options = {
  hostname: url.hostname,
  path: url.pathname + url.search,
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(JSON.parse(data)); });
});

req.on('error', (err) => { console.error(err); });
req.end();
require 'net/http'
require 'uri'
require 'json'

url = URI("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate")
params = {
  "attachment_ids" => "[12345678987654321]",
  "entity_type" => "task",
  "entity_id" => "1752587000000097299",
  "project_id" => "23806000097545166"
}
url.query = URI.encode_www_form(params)

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Authorization"] = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"

response = http.request(request)
puts response.read_body
<?php
$params = [
    'attachment_ids' => '[12345678987654321]',
    'entity_type' => 'task',
    'entity_id' => '1752587000000097299',
    'project_id' => '23806000097545166',
];
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate" . "?" . http_build_query($params);

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
import requests

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate"

params = {
    "attachment_ids": "[12345678987654321]",
    "entity_type": "task",
    "entity_id": "1752587000000097299",
    "project_id": "23806000097545166"
}

headers = {
    "Authorization": "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
}

response = requests.delete(url, headers=headers, params=params)

print(response.json())
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl) {
        char *enc_attachment_ids = curl_easy_escape(curl, "[12345678987654321]", 0);
        char *enc_entity_type = curl_easy_escape(curl, "task", 0);
        char *enc_entity_id = curl_easy_escape(curl, "1752587000000097299", 0);
        char *enc_project_id = curl_easy_escape(curl, "23806000097545166", 0);
        char url[2048];
        snprintf(url, sizeof(url), "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate?attachment_ids=%s&entity_type=%s&entity_id=%s&project_id=%s", enc_attachment_ids, enc_entity_type, enc_entity_id, enc_project_id);

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");

        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));

        curl_free(enc_attachment_ids);
        curl_free(enc_entity_type);
        curl_free(enc_entity_id);
        curl_free(enc_project_id);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
using System.Net.Http;
using System.Text;
using System.Web;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

var query = HttpUtility.ParseQueryString(string.Empty);
query["attachment_ids"] = "[12345678987654321]";
query["entity_type"] = "task";
query["entity_id"] = "1752587000000097299";
query["project_id"] = "23806000097545166";
var uriBuilder = new UriBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate") { Query = query.ToString() };
var request = new HttpRequestMessage(HttpMethod.Delete, uriBuilder.Uri);

var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
    output->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;
        char* enc_attachment_ids = curl_easy_escape(curl, "[12345678987654321]", 0);
        char* enc_entity_type = curl_easy_escape(curl, "task", 0);
        char* enc_entity_id = curl_easy_escape(curl, "1752587000000097299", 0);
        char* enc_project_id = curl_easy_escape(curl, "23806000097545166", 0);
        std::string url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate";
        url += "?attachment_ids=" + std::string(enc_attachment_ids);
        url += "&entity_type=" + std::string(enc_entity_type);
        url += "&entity_id=" + std::string(enc_entity_id);
        url += "&project_id=" + std::string(enc_project_id);

        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK)
            std::cout << response << std::endl;
        else
            std::cerr << curl_easy_strerror(res) << std::endl;

        curl_free(enc_attachment_ids);
        curl_free(enc_entity_type);
        curl_free(enc_entity_id);
        curl_free(enc_project_id);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
(require '[clj-http.client :as client])

(let [enc-attachment_ids (java.net.URLEncoder/encode "[12345678987654321]" "UTF-8")
      enc-entity_type (java.net.URLEncoder/encode "task" "UTF-8")
      enc-entity_id (java.net.URLEncoder/encode "1752587000000097299" "UTF-8")
      enc-project_id (java.net.URLEncoder/encode "23806000097545166" "UTF-8")
      url (str "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate" "?attachment_ids=" enc-attachment_ids "&entity_type=" enc-entity_type "&entity_id=" enc-entity_id "&project_id=" enc-project_id)]
(def response
  (client/delete url
    {:headers {"Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"}
     :as :json}))

(println (:body response))
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
)

func main() {
    req, _ := http.NewRequest("DELETE", "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate", nil)
    q := req.URL.Query()
    q.Add("attachment_ids", "[12345678987654321]")
    q.Add("entity_type", "task")
    q.Add("entity_id", "1752587000000097299")
    q.Add("project_id", "23806000097545166")
    req.URL.RawQuery = q.Encode()
    req.Header.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
DELETE https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate?attachment_ids=%5B12345678987654321%5D&entity_type=task&entity_id=1752587000000097299&project_id=23806000097545166 HTTP/1.1
Host: https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate?attachment_ids=%5B12345678987654321%5D&entity_type=task&entity_id=1752587000000097299&project_id=23806000097545166
Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();

URIBuilder uriBuilder = new URIBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate");
uriBuilder.addParameter("attachment_ids", "[12345678987654321]");
uriBuilder.addParameter("entity_type", "task");
uriBuilder.addParameter("entity_id", "1752587000000097299");
uriBuilder.addParameter("project_id", "23806000097545166");
HttpUriRequest requestObj = new HttpDelete(uriBuilder.build());
requestObj.addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

HttpResponse response = httpclient.execute(requestObj);

HttpEntity responseEntity = response.getEntity();
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
const url = 'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate';

const params = new URLSearchParams({
  'attachment_ids': '[12345678987654321]',
  'entity_type': 'task',
  'entity_id': '1752587000000097299',
  'project_id': '23806000097545166'
});

const options = {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  }
};

fetch(url + '?' + params.toString(), options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));
attachment_ids = "[12345678987654321]"
entity_type = "task"
entity_id = "1752587000000097299"
project_id = "23806000097545166"
import java.net.HttpURLConnection
import java.net.URL
import okhttp3.HttpUrl.Companion.toHttpUrl

fun main() {
    val urlBuilder = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate".toHttpUrl().newBuilder()
    urlBuilder.addQueryParameter("attachment_ids", "[12345678987654321]")
    urlBuilder.addQueryParameter("entity_type", "task")
    urlBuilder.addQueryParameter("entity_id", "1752587000000097299")
    urlBuilder.addQueryParameter("project_id", "23806000097545166")
    val url = URL(urlBuilder.build().toString())
    val conn = url.openConnection() as HttpURLConnection
    conn.requestMethod = "DELETE"
    conn.setRequestProperty("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")

    val response = conn.inputStream.bufferedReader().readText()
    println(response)
}
NSString *encodedAttachment_ids = [@"[12345678987654321]" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *encodedEntity_type = [@"task" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *encodedEntity_id = [@"1752587000000097299" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *encodedProject_id = [@"23806000097545166" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *urlString = [NSString stringWithFormat:@"https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate?attachment_ids=%@&entity_type=%@&entity_id=%@&project_id=%@", encodedAttachment_ids, encodedEntity_type, encodedEntity_id, encodedProject_id];
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"DELETE"];
[request setValue:@"Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa" forHTTPHeaderField:@"Authorization"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@", result);
}];
[task resume];
open Lwt
open Cohttp_lwt_unix

let () =
  let enc_attachment_ids = Uri.pct_encode "[12345678987654321]" in
  let enc_entity_type = Uri.pct_encode "task" in
  let enc_entity_id = Uri.pct_encode "1752587000000097299" in
  let enc_project_id = Uri.pct_encode "23806000097545166" in
  let uri = Uri.of_string ("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate" ^ "?attachment_ids=" ^ enc_attachment_ids ^ "&entity_type=" ^ enc_entity_type ^ "&entity_id=" ^ enc_entity_id ^ "&project_id=" ^ enc_project_id) in
  let headers = Cohttp.Header.init ()
    |> fun h -> Cohttp.Header.add h "Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  in
  Lwt_main.run (
    Client.delete ~headers uri >>= fun (_, body) ->
    Cohttp_lwt.Body.to_string body >|= fun s ->
    print_endline s)
$headers = @{
    "Authorization" = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
}

$params = @{
    attachment_ids = "[12345678987654321]"
    entity_type = "task"
    entity_id = "1752587000000097299"
    project_id = "23806000097545166"
}
$queryString = ($params.GetEnumerator() | ForEach-Object { "$($_.Key)=$([System.Uri]::EscapeDataString($_.Value))" }) -join "&"
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate" + "?" + $queryString

$response = Invoke-RestMethod -Uri $url -Method DELETE -Headers $headers

$response | ConvertTo-Json
library(httr)

url <- "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate"

params <- list(
  attachment_ids = "[12345678987654321]",
  entity_type = "task",
  entity_id = "1752587000000097299",
  project_id = "23806000097545166"
)

response <- DELETE(
  url,
  add_headers(Authorization = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"),
  query = params
)

content(response, "text")
import Foundation

var components = URLComponents(string: "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/attachments/disassociate")!
components.queryItems = [
    URLQueryItem(name: "attachment_ids", value: "[12345678987654321]"),
    URLQueryItem(name: "entity_type", value: "task"),
    URLQueryItem(name: "entity_id", value: "1752587000000097299"),
    URLQueryItem(name: "project_id", value: "23806000097545166")
]
let url = components.url!
var request = URLRequest(url: url)
request.httpMethod = "DELETE"
request.setValue("Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa", forHTTPHeaderField: "Authorization")

let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data, let result = String(data: data, encoding: .utf8) {
        print(result)
    }
    semaphore.signal()
}
task.resume()
semaphore.wait()

Sample Input

attachment_ids : "[12345678987654321]" entity_type : "task" entity_id : "1752587000000097299" project_id : "23806000097545166"

Sample Response

200{ "status" : "success" }

Add Attachments to Comments

Upload files within a comment. These files will be shown along with the comment content

POST

/api/v3/portal/[PORTAL_ID]/inline-attachments

OAuth Scope:

ZohoProjects.portals.CREATE

Path Parameters

Param Name
Data Type
Description

File Parameters

Param Name
Data Type
Description

Request Example

Request Example
  • cURL
  • Deluge
  • Node.js
  • Ruby
  • PHP
  • Python
  • C
  • C#
  • C++
  • Clojure
  • Go
  • HTTP
  • Java
  • JS Fetch
  • JSON
  • Kotlin
  • Objective-C
  • OCaml
  • PowerShell
  • R
  • Swift

curl -X POST \
'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments' \
-H 'Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa' \
--form 'img_file=@/path/to/file'

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments";

fileObj = invokeUrl
[
    url: "/path/to/file"
    type: GET
];

response = invokeUrl
[
    url: url
    type: POST
    files: {"img_file": fileObj}
    connection: "projects"
];

info response;
const fs = require('fs');
const FormData = require('form-data');
const https = require('https');

const form = new FormData();
form.append('img_file', fs.createReadStream('/path/to/file'));

const url = new URL('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments');

const options = {
  hostname: url.hostname,
  path: url.pathname,
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa',
    ...form.getHeaders()
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(JSON.parse(data)); });
});

req.on('error', (err) => { console.error(err); });
form.pipe(req);
require 'net/http'
require 'uri'

url = URI("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post::Multipart.new(url, {
  "img_file" => UploadIO.new(File.new("/path/to/file"), "application/octet-stream")
})
request["Authorization"] = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"

response = http.request(request)
puts response.read_body
<?php

$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments";

$postFields = [
    'img_file' => new CURLFile('/path/to/file'),
];

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => $postFields,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
import requests

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments"

headers = {
    "Authorization": "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
}

files = {
    "img_file": open("/path/to/file", "rb")
}

response = requests.post(url, headers=headers, files=files)

print(response.json())
#include <stdio.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl) {
        curl_mime *mime = curl_mime_init(curl);
        curl_mimepart *part = curl_mime_addpart(mime);
        curl_mime_name(part, "img_file");
        curl_mime_filedata(part, "/path/to/file");

        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);

        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));

        curl_mime_free(mime);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
using System.Net.Http;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

var content = new MultipartFormDataContent();
var fileStream = File.OpenRead("/path/to/file");
content.Add(new StreamContent(fileStream), "img_file", "file");

var request = new HttpRequestMessage(HttpMethod.Post, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments") { Content = content };
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
    output->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;

        curl_mime* mime = curl_mime_init(curl);
        curl_mimepart* part = curl_mime_addpart(mime);
        curl_mime_name(part, "img_file");
        curl_mime_filedata(part, "/path/to/file");

        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK)
            std::cout << response << std::endl;
        else
            std::cerr << curl_easy_strerror(res) << std::endl;

        curl_mime_free(mime);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
(require '[clj-http.client :as client])
(require '[clojure.java.io :as io])

(def response
  (client/post "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments"
    {:headers {"Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"}
     :multipart [{:name "img_file"
                  :content (io/file "/path/to/file")}]}))

(println (:body response))
package main

import (
    "bytes"
    "fmt"
    "io"
    "mime/multipart"
    "net/http"
    "os"
)

func main() {
    body := &bytes.Buffer{}
    writer := multipart.NewWriter(body)

    file, _ := os.Open("/path/to/file")
    defer file.Close()
    part, _ := writer.CreateFormFile("img_file", "file")
    io.Copy(part, file)
    writer.Close()

    req, _ := http.NewRequest("POST", "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments", body)
    req.Header.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")
    req.Header.Add("Content-Type", writer.FormDataContentType())

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    respBody, _ := io.ReadAll(resp.Body)
    fmt.Println(string(respBody))
}
POST https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments HTTP/1.1
Host: https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments
Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa
Content-Type: multipart/form-data; boundary=----FormBoundary

------FormBoundary
Content-Disposition: form-data; name="img_file"; filename="file"
Content-Type: application/octet-stream

[file content]
------FormBoundary--
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();

HttpEntityEnclosingRequestBase httpRequest = new HttpPost("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments");
httpRequest.addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("img_file", new File("/path/to/file"), ContentType.DEFAULT_BINARY, "file");
httpRequest.setEntity(builder.build());

HttpResponse response = httpclient.execute(httpRequest);

HttpEntity responseEntity = response.getEntity();
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
const formData = new FormData();
formData.append('img_file', fileInput.files[0]);

fetch('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa'
  },
  body: formData
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));
{
  "img_file": "(binary file data)"
}
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import java.io.File

fun main() {
    val client = OkHttpClient()

    val file = File("/path/to/file")
    val body = MultipartBody.Builder()
        .setType(MultipartBody.FORM)
        .addFormDataPart("img_file", file.name, RequestBody.create(file, "application/octet-stream".toMediaType()))
        .build()

    val request = Request.Builder()
        .url("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments")
        .method("POST", body)
        .addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")
        .build()

    val response = client.newCall(request).execute()
    println(response.body?.string())
}
NSURL *url = [NSURL URLWithString:@"https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa" forHTTPHeaderField:@"Authorization"];

NSString *boundary = [[NSUUID UUID] UUIDString];
[request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary] forHTTPHeaderField:@"Content-Type"];

NSMutableData *body = [NSMutableData data];
NSData *fileData = [NSData dataWithContentsOfFile:@"/path/to/file"];
[body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"img_file\"; filename=\"file\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:fileData];
[body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@", result);
}];
[task resume];
open Lwt
open Cohttp_lwt_unix

let () =
  let uri = Uri.of_string "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments" in
  let file_content = Lwt_io.(with_file ~mode:Input "/path/to/file" read) in
  let boundary = "----FormBoundary" in
  let body_str =
    "--" ^ boundary ^ "\r\n" ^
    "Content-Disposition: form-data; name=\"img_file\"; filename=\"file\"\r\n" ^
    "Content-Type: application/octet-stream\r\n\r\n" ^
    file_content ^ "\r\n" ^
    "--" ^ boundary ^ "--\r\n" in
  let headers = Cohttp.Header.init ()
    |> fun h -> Cohttp.Header.add h "Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
    |> fun h -> Cohttp.Header.add h "Content-Type" ("multipart/form-data; boundary=" ^ boundary)
  in
  let body = Cohttp_lwt.Body.of_string body_str in
  Lwt_main.run (
    Client.post ~headers ~body uri >>= fun (_, body) ->
    Cohttp_lwt.Body.to_string body >|= fun s ->
    print_endline s)
$headers = @{
    "Authorization" = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
}

$form = @{
    img_file = Get-Item -Path "/path/to/file"
}

$response = Invoke-RestMethod -Uri "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments" -Method POST -Headers $headers -Form $form

$response | ConvertTo-Json
library(httr)

url <- "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments"

response <- POST(
  url,
  add_headers(Authorization = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"),
  body = list(
    img_file = upload_file("/path/to/file")
  ),
  encode = "multipart"
)

content(response, "text")
import Foundation

let url = URL(string: "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/inline-attachments")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa", forHTTPHeaderField: "Authorization")

let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")

var body = Data()
let fileData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/file"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"img_file\"; filename=\"file\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(fileData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body

let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data, let result = String(data: data, encoding: .utf8) {
        print(result)
    }
    semaphore.signal()
}
task.resume()
semaphore.wait()

Sample Response

200{ "inline_attachment" : { "content_type" : "image/png", "file_id" : "170876000015600001", "name" : "inline_image.png", "url" : "viewInlineAttachment/image?file=projects-<attachment_key>" } }

Upload Base64 Encoded Files

Upload files to Zoho WorkDrive from Zoho Projects using Base64 encoded content.

POST

/api/v3/portal/[PORTAL_ID]/upload-attachments

OAuth Scope:

ZohoProjects.portals.CREATE

Path Parameters

Param Name
Data Type
Description

Body Parameters

Param Name
Data Type
Description

Request Example

Request Example
  • cURL
  • Deluge
  • Node.js
  • Ruby
  • PHP
  • Python
  • C
  • C#
  • C++
  • Clojure
  • Go
  • HTTP
  • Java
  • JS Fetch
  • JSON
  • Kotlin
  • Objective-C
  • OCaml
  • PowerShell
  • R
  • Swift

curl -X POST \
'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments' \
-H 'Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa' \
-H 'Content-Type: application/json' \
-d '{"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]}'

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments";
params = Map();
params.put("workdrive_info", {"location":{"folder_id":"-","new_version":"-"}});
params.put("upload_files", [{"name":"-","content":"-"}]);
response = invokeUrl
[
    url: url
    type: POST
    parameters: params.toString()
    connection: "projects"
];
info response;
const https = require('https');
const url = new URL('https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments');

const payload = JSON.stringify({"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]});

const options = {
  hostname: url.hostname,
  path: url.pathname + url.search,
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa',
    'Content-Type': 'application/json',
    'Content-Length': Buffer.byteLength(payload)
  }
};

const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(JSON.parse(data)); });
});

req.on('error', (err) => { console.error(err); });
req.write(payload);
req.end();
require 'net/http'
require 'uri'
require 'json'

url = URI("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
request["Content-Type"] = "application/json"
request.body = '{"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]}'

response = http.request(request)
puts response.read_body
<?php
$url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments";

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => '{"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]}',
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
import requests

url = "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments"

headers = {
    "Authorization": "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa",
    "Content-Type": "application/json",
}

payload = '{"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]}'

response = requests.post(url, headers=headers, data=payload)

print(response.json())
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl) {
        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");
        headers = curl_slist_append(headers, "Content-Type: application/json");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"workdrive_info\":{\"location\":{\"folder_id\":\"-\",\"new_version\":\"-\"}},\"upload_files\":[{\"name\":\"-\",\"content\":\"-\"}]}");

        CURLcode res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));

        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
using System.Net.Http;
using System.Text;
using System.Web;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

var request = new HttpRequestMessage(HttpMethod.Post, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments");
request.Content = new StringContent(
    @"{""workdrive_info"":{""location"":{""folder_id"":""-"",""new_version"":""-""}},""upload_files"":[{""name"":""-"",""content"":""-""}]}",
    Encoding.UTF8,
    "application/json"
);

var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
    output->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;
        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");
        headers = curl_slist_append(headers, "Content-Type: application/json");

        curl_easy_setopt(curl, CURLOPT_URL, "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"workdrive_info\":{\"location\":{\"folder_id\":\"-\",\"new_version\":\"-\"}},\"upload_files\":[{\"name\":\"-\",\"content\":\"-\"}]}");

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK)
            std::cout << response << std::endl;
        else
            std::cerr << curl_easy_strerror(res) << std::endl;

        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
    }
    return 0;
}
(require '[clj-http.client :as client])

(def response
  (client/post "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments"
    {:headers {"Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
                "Content-Type" "application/json"}
     :body "{\"workdrive_info\":{\"location\":{\"folder_id\":\"-\",\"new_version\":\"-\"}},\"upload_files\":[{\"name\":\"-\",\"content\":\"-\"}]}"
     :as :json}))

(println (:body response))
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    payload := strings.NewReader("{\"workdrive_info\":{\"location\":{\"folder_id\":\"-\",\"new_version\":\"-\"}},\"upload_files\":[{\"name\":\"-\",\"content\":\"-\"}]}")
    req, _ := http.NewRequest("POST", "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments", payload)
    req.Header.Add("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")
    req.Header.Add("Content-Type", "application/json")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
POST https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments HTTP/1.1
Host: https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments
Authorization: Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa
Content-Type: application/json

{"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]}
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();

URIBuilder uriBuilder = new URIBuilder("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments");
HttpUriRequest requestObj = new HttpPost(uriBuilder.build());
requestObj.addHeader("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa");

HttpEntityEnclosingRequestBase requestBase = (HttpEntityEnclosingRequestBase) requestObj;
String requestBody = "{\"workdrive_info\":{\"location\":{\"folder_id\":\"-\",\"new_version\":\"-\"}},\"upload_files\":[{\"name\":\"-\",\"content\":\"-\"}]}";
requestBase.setEntity(new StringEntity(requestBody, HTTP.UTF_8));

HttpResponse response = httpclient.execute(requestObj);

HttpEntity responseEntity = response.getEntity();
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
const url = 'https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments';

const options = {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]})
};

fetch(url, options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));
{"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]}
import java.net.HttpURLConnection
import java.net.URL
import okhttp3.HttpUrl.Companion.toHttpUrl

fun main() {
    val url = URL("https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments")
    val conn = url.openConnection() as HttpURLConnection
    conn.requestMethod = "POST"
    conn.setRequestProperty("Authorization", "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa")
    conn.setRequestProperty("Content-Type", "application/json")
    conn.doOutput = true
    conn.outputStream.bufferedWriter().use { it.write("""{"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]}""") }

    val response = conn.inputStream.bufferedReader().readText()
    println(response)
}
NSURL *url = [NSURL URLWithString:@"https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa" forHTTPHeaderField:@"Authorization"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSData *body = [@"{\"workdrive_info\":{\"location\":{\"folder_id\":\"-\",\"new_version\":\"-\"}},\"upload_files\":[{\"name\":\"-\",\"content\":\"-\"}]}" dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:body];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@", result);
}];
[task resume];
open Lwt
open Cohttp_lwt_unix

let () =
  let uri = Uri.of_string "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments" in
  let headers = Cohttp.Header.init ()
    |> fun h -> Cohttp.Header.add h "Authorization" "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
    |> fun h -> Cohttp.Header.add h "Content-Type" "application/json"
  in
  let body = Cohttp_lwt.Body.of_string {json|{"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]}|json} in
  Lwt_main.run (
    Client.post ~headers ~body uri >>= fun (_, body) ->
    Cohttp_lwt.Body.to_string body >|= fun s ->
    print_endline s)
$headers = @{
    "Authorization" = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"
    "Content-Type" = "application/json"
}

$body = @'
{"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]}
'@

$response = Invoke-RestMethod -Uri "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments" -Method POST -Headers $headers -Body $body

$response | ConvertTo-Json
library(httr)

url <- "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments"

response <- POST(
  url,
  add_headers(Authorization = "Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa"),
  content_type_json(),
  body = "{\"workdrive_info\":{\"location\":{\"folder_id\":\"-\",\"new_version\":\"-\"}},\"upload_files\":[{\"name\":\"-\",\"content\":\"-\"}]}"
)

content(response, "text")
import Foundation

let url = URL(string: "https://projects.zoho.com/api/v3/portal/[PORTAL_ID]/upload-attachments")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer 1000.03xxxxxxxxxxxxxxxxxa5317.dxxxxxxxxxxxxxxxxxfa", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = """
{"workdrive_info":{"location":{"folder_id":"-","new_version":"-"}},"upload_files":[{"name":"-","content":"-"}]}
""".data(using: .utf8)

let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data, let result = String(data: data, encoding: .utf8) {
        print(result)
    }
    semaphore.signal()
}
task.resume()
semaphore.wait()

Sample Input

Content-Type: application/json
{ "workdrive_info" : { "location" : { "folder_id" : "-", "new_version" : "-" } }, "upload_files" : [ { "name" : "-", "content" : "-" } ] }

Sample Response

201{ "attachments" : [ { "id" : "4000000101001", "name" : "base64image.png", "type" : "image/png", "size" : 1661126, "third_party_file_id" : "ae4mwe9013aa6e770436aa1e90d613b0dc1c9", "uploaded_by" : { "name" : "Vignesh", "zpuid" : "4000000002007" }, "uploaded_time" : "2026-10-01T11:43:42.702Z", "preview_url" : "https://previewengine.zoho.com/thumbnail/WD/ae4mwe9013aa6e770436aa1e90d613b0dc1c9", "download_url" : "https://download.zoho.com/v1/workdrive/download/ae4mwe9013aa6e770436aa1e90d613b0dc1c9", "permanent_url" : "https://workdrive.zoho.com/file/ae4mwe9013aa6e770436aa1e90d613b0dc1c9" } ] }
AI Tools
ChatGPT Open in ChatGPT ↗ Open in ChatGPT to ask questions about this page
Claude Open in Claude ↗ Open in Claude to ask questions about this page
Copy as Markdown Copy this page as markdown to use with AI assistants
View as Markdown ↗ Open this page as markdown in a new tab
Copy OpenAPI Spec Copy the OpenAPI YAML to the clipboard
View as YAML ↗ Open the OpenAPI spec in a new tab
Download YAML Save the OpenAPI spec as a .yaml file