<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes
Contract Note
Use contract note to add additional information, including technical information, to a particular contract based on your observations.
Attributes
id (long)
Unique identifier to identify the note
description (html)
Contains the description of the note
notify_to (notify_to)
Contains the list of users to notify
attachments (attachment)
Indicates the attachments of the note.
performed_by (user)read only
Indicates the user who created the note
performed_time (datetime)read only
Indicates the created time of the note
Add Contract Note
Use this operation to add a note
Mandatory Fields :- description
Url
Attributes
id (long)
Unique identifier to identify the note
description (html)
Contains the description of the note
notify_to (notify_to)
Contains the list of users to notify
attachments (attachment)
Indicates the attachments of the note.
performed_by (user)read only
Indicates the user who created the note
performed_time (datetime)read only
Indicates the created time of the note
$ curl <service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes\
-X POST\
-H "Accept: application/vnd.manageengine.sdp.v3+json"\
-H "Authorization: Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"\
-H "Content-Type: application/x-www-form-urlencoded"\
-d input_data='{
"note": {
"description": "<div class=\"personalize-wrapper\" style=\"font-family: 'PT Sans',Arial,Helvetica,sans-serif, sans-serif;font-size: 13px;\" > <div>CONVERSATION NOTE</div> </div>",
"notify_to": {
"to": [
"test@zmail.com"
]
},
"attachments": [
{
"file_id": "1004"
}
]
}
}'
// Deluge Sample script
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes";
headers = {"Accept":"application/vnd.manageengine.sdp.v3+json",
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"};
input_data = {
"note": {
"description": "<div class=\"personalize-wrapper\" style=\"font-family: 'PT Sans',Arial,Helvetica,sans-serif, sans-serif;font-size: 13px;\" > <div>CONVERSATION NOTE</div> </div>",
"notify_to": {
"to": [
"test@zmail.com"
]
},
"attachments": [
{
"file_id": "1004"
}
]
}
};
params = {"input_data": input_data};
response = invokeurl
[
url: url
type: POST
parameters: params
headers: headers
];
info response;
#Powershell version - 5.1
$url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes"
$headers = @{ "Accept" = "application/vnd.manageengine.sdp.v3+json"
"Authorization" = "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"
"Content-Type" = "application/x-www-form-urlencoded"}
$input_data = @'
{
"note": {
"description": "<div class=\"personalize-wrapper\" style=\"font-family: 'PT Sans',Arial,Helvetica,sans-serif, sans-serif;font-size: 13px;\" > <div>CONVERSATION NOTE</div> </div>",
"notify_to": {
"to": [
"test@zmail.com"
]
},
"attachments": [
{
"file_id": "1004"
}
]
}
}
'@
$data = @{ 'input_data' = $input_data}
$response = Invoke-RestMethod -Uri $url -Method post -Body $data -Headers $headers
$response
#Python version - 3.10
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import urlopen,Request
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes"
headers ={"Accept": "application/vnd.manageengine.sdp.v3+json",
"Authorization" : "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx",
"Content-Type" : "application/x-www-form-urlencoded"}
input_data = '''{
"note": {
"description": "<div class=\"personalize-wrapper\" style=\"font-family: 'PT Sans',Arial,Helvetica,sans-serif, sans-serif;font-size: 13px;\" > <div>CONVERSATION NOTE</div> </div>",
"notify_to": {
"to": [
"test@zmail.com"
]
},
"attachments": [
{
"file_id": "1004"
}
]
}
}'''
data = urlencode({"input_data":input_data}).encode()
httprequest = Request(url, headers=headers,data=data, method="POST")
try:
with urlopen(httprequest) as response:
print(response.read().decode())
except HTTPError as e:
print(e.read().decode())
{
"note": {
"attachments": [
{
"size": "119747",
"content_type": "application/pdf",
"file_id": "1004",
"name": "samplepo.pdf",
"content_url": "/contracts/100000000000039185/notes/100000000000039354/_uploads/1004",
"id": "100000000000039362"
}
],
"performed_by": {
"email_id": "test1@zmail.com",
"is_technician": true,
"sms_mail": null,
"mobile": null,
"last_name": "test1",
"user_scope": "internal_user",
"sms_mail_id": null,
"site": {
"deleted": false,
"name": "Base Site",
"id": "100000000000006130",
"is_default": true
},
"phone": null,
"employee_id": null,
"name": "test",
"id": "100000000000036225",
"photo_url": "test-photo_url",
"is_vip_user": false,
"department": null,
"first_name": "test",
"job_title": null
},
"description": "<div class=\"personalize-wrapper\" style=\"font-family: "PT Sans", Arial, Helvetica, sans-serif, sans-serif; font-size: 13px\"> <div>CONVERSATION NOTE</div> </div>",
"id": "100000000000039354",
"performed_time": {
"display_value": "Apr 6, 2023 04:29 PM",
"value": "1680778760949"
}
},
"response_status": {
"status_code": 2000,
"status": "success"
}
}
Edit Contract Note
Use this operation to edit a note
Url
<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}
Attributes
id (long)
Unique identifier to identify the note
description (html)
Contains the description of the note
notify_to (notify_to)
Contains the list of users to notify
attachments (attachment)
Indicates the attachments of the note.
performed_by (user)read only
Indicates the user who created the note
performed_time (datetime)read only
Indicates the created time of the note
$ curl <service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}\
-X PUT\
-H "Accept: application/vnd.manageengine.sdp.v3+json"\
-H "Authorization: Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"\
-H "Content-Type: application/x-www-form-urlencoded"\
-d input_data='{
"note": {
"description": "<div class=\"personalize-wrapper\" style=\"font-family: "PT Sans", Arial, Helvetica, sans-serif, sans-serif; font-size: 13px\"><div>TESTCONVERSATION EDITTED<br></div></div>",
"notify_to": {
"to": [
"test@zmail.com"
]
},
"attachments": []
}
}'
// Deluge Sample script
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}";
headers = {"Accept":"application/vnd.manageengine.sdp.v3+json",
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"};
input_data = {
"note": {
"description": "<div class=\"personalize-wrapper\" style=\"font-family: "PT Sans", Arial, Helvetica, sans-serif, sans-serif; font-size: 13px\"><div>TESTCONVERSATION EDITTED<br></div></div>",
"notify_to": {
"to": [
"test@zmail.com"
]
},
"attachments": []
}
};
params = {"input_data": input_data};
response = invokeurl
[
url: url
type: PUT
parameters: params
headers: headers
];
info response;
#Powershell version - 5.1
$url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}"
$headers = @{"Accept": "application/vnd.manageengine.sdp.v3+json",
"Authorization" : "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx",
"Content-Type" : "application/x-www-form-urlencoded"}
$input_data = @'
{
"note": {
"description": "<div class=\"personalize-wrapper\" style=\"font-family: "PT Sans", Arial, Helvetica, sans-serif, sans-serif; font-size: 13px\"><div>TESTCONVERSATION EDITTED<br></div></div>",
"notify_to": {
"to": [
"test@zmail.com"
]
},
"attachments": []
}
}
'@
$data = @{ 'input_data' = $input_data}
$response = Invoke-RestMethod -Uri $url -Method put -Body $data -Headers $headers
$response
#Python version - 3.10
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import urlopen,Request
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}"
headers ={"Accept": "application/vnd.manageengine.sdp.v3+json",
"Authorization" : "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx",
"Content-Type" : "application/x-www-form-urlencoded"}
input_data = '''{
"note": {
"description": "<div class=\"personalize-wrapper\" style=\"font-family: "PT Sans", Arial, Helvetica, sans-serif, sans-serif; font-size: 13px\"><div>TESTCONVERSATION EDITTED<br></div></div>",
"notify_to": {
"to": [
"test@zmail.com"
]
},
"attachments": []
}
}'''
data = urlencode({"input_data":input_data}).encode()
httprequest = Request(url, headers=headers,data=data, method="PUT")
try:
with urlopen(httprequest) as response:
print(response.read().decode())
except HTTPError as e:
print(e.read().decode())
{
"note": {
"attachments": [],
"performed_by": {
"email_id": "test@zmail.com",
"is_technician": true,
"sms_mail": null,
"mobile": null,
"last_name": "test",
"user_scope": "internal_user",
"sms_mail_id": null,
"site": {
"deleted": false,
"name": "Base Site",
"id": "100000000000006130",
"is_default": true
},
"phone": null,
"employee_id": null,
"name": "test",
"id": "100000000000036225",
"photo_url": "test-photo_url",
"is_vip_user": false,
"department": null,
"first_name": "test",
"job_title": null
},
"description": "<div class=\"personalize-wrapper\" style=\"font-family: "PT Sans", Arial, Helvetica, sans-serif, sans-serif; font-size: 13px\"><div>TESTCONVERSATION EDITTED<br /></div></div>",
"id": "100000000000037591",
"performed_time": {
"display_value": "Mar 31, 2023 06:43 PM",
"value": "1680268438250"
}
},
"response_status": {
"status_code": 2000,
"status": "success"
}
}
Get Contract Note
Use this operation to get a note from a contract
Url
<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}
Attributes
id (long)
Unique identifier to identify the note
description (html)
Contains the description of the note
notify_to (notify_to)
Contains the list of users to notify
attachments (attachment)
Indicates the attachments of the note.
performed_by (user)read only
Indicates the user who created the note
performed_time (datetime)read only
Indicates the created time of the note
$ curl -G <service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}\
-X GET\
-H "Accept: application/vnd.manageengine.sdp.v3+json"\
-H "Authorization: Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"\
-H "Content-Type: application/x-www-form-urlencoded"
// Deluge Sample script
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}";
headers = {"Accept":"application/vnd.manageengine.sdp.v3+json",
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"};
response = invokeurl
[
url: url
type: GET
headers: headers
];
info response;
#Powershell version - 5.1
$url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}"
$headers = @{ "Accept" = "application/vnd.manageengine.sdp.v3+json"
"Authorization" = "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"
"Content-Type" = "application/x-www-form-urlencoded"}
$response = Invoke-RestMethod -Uri $url -Method get -Headers $headers
$response
#Python version - 3.8
#This script requires requests module installed in python.
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import urlopen,Request
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}"
headers ={"Accept": "application/vnd.manageengine.sdp.v3+json",
"Authorization" : "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx",
"Content-Type" : "application/x-www-form-urlencoded"}
httprequest = Request(url, headers=headers)
try:
with urlopen(httprequest) as response:
print(response.read().decode())
except HTTPError as e:
print(e.read().decode())
{
"note": {
"attachments": [],
"performed_by": {
"email_id": "test@zmail.com",
"is_technician": true,
"sms_mail": null,
"mobile": "xxxxxxxxxxxx",
"last_name": "T",
"user_scope": "internal_user",
"sms_mail_id": null,
"site": {
"deleted": false,
"name": "Base Site",
"id": "2000000006130",
"is_default": true
},
"phone": "",
"employee_id": null,
"name": "Test",
"id": "2000000036237",
"photo_url": "photo-test-url",
"is_vip_user": false,
"department": null,
"first_name": "Test",
"job_title": null
},
"description": "<div class=\"personalize-wrapper\" style=\"font-family: "PT Sans", Arial, Helvetica, sans-serif, sans-serif; font-size: 13px\"> <div>Contract Notes</div> </div>",
"id": "2000000037037",
"performed_time": {
"display_value": "Apr 17, 2023 06:27 PM",
"value": "1681736255194"
}
},
"response_status": {
"status_code": 2000,
"status": "success"
}
}
Get List Contract Note
Use this operation to get a list of all notes
Url
<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes
Attributes
id (long)
Unique identifier to identify the note
description (html)
Contains the description of the note
notify_to (notify_to)
Contains the list of users to notify
attachments (attachment)
Indicates the attachments of the note.
performed_by (user)read only
Indicates the user who created the note
performed_time (datetime)read only
Indicates the created time of the note
$ curl -G <service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes\
-X GET\
-H "Accept: application/vnd.manageengine.sdp.v3+json"\
-H "Authorization: Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"\
-H "Content-Type: application/x-www-form-urlencoded"\
--data-urlencode input_data='{}'
// Deluge Sample script
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes";
headers = {"Accept":"application/vnd.manageengine.sdp.v3+json",
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"};
input_data = {};
params = {"input_data":input_data};
response = invokeurl
[
url: url
type: GET
parameters:params
headers: headers
];
info response;
#Powershell version - 5.1
$url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes"
$headers = @{ "Accept" = "application/vnd.manageengine.sdp.v3+json"
"Authorization" = "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"
"Content-Type" = "application/x-www-form-urlencoded"}
$input_data = @'{}'@
$data = @{ 'input_data' = $input_data}
$response = Invoke-RestMethod -Uri $url -Method get -Body $data -Headers $headers
$response
#Python version - 3.8
#This script requires requests module installed in python.
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import urlopen,Request
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes"
headers ={"Accept": "application/vnd.manageengine.sdp.v3+json",
"Authorization" : "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx",
"Content-Type" : "application/x-www-form-urlencoded"}
input_data = '''{}'''
url += "?" + urlencode({"input_data":input_data})
httprequest = Request(url, headers=headers)
try:
with urlopen(httprequest) as response:
print(response.read().decode())
except HTTPError as e:
print(e.read().decode())
{
"notes": [
{
"performed_by": {
"email_id": "test1@zmail.com",
"is_technician": true,
"sms_mail": null,
"mobile": null,
"last_name": "test1",
"user_scope": "internal_user",
"sms_mail_id": null,
"site": {
"deleted": false,
"name": "Base Site",
"id": "100000000000006130",
"is_default": true
},
"phone": null,
"employee_id": null,
"name": "test",
"id": "100000000000036225",
"photo_url": "test-photo_url",
"is_vip_user": false,
"department": null,
"first_name": "test",
"job_title": null
},
"description": "CONVERSATION NOTE",
"id": "100000000000039354",
"performed_time": {
"display_value": "Apr 6, 2023 04:29 PM",
"value": "1680778760949"
}
},
{
"performed_by": {
"email_id": "test1@zmail.com",
"is_technician": true,
"sms_mail": null,
"mobile": null,
"last_name": "test1",
"user_scope": "internal_user",
"sms_mail_id": null,
"site": {
"deleted": false,
"name": "Base Site",
"id": "100000000000006130",
"is_default": true
},
"phone": null,
"employee_id": null,
"name": "test",
"id": "100000000000036225",
"photo_url": "test-photo_url",
"is_vip_user": false,
"department": null,
"first_name": "test",
"job_title": null
},
"description": "CONVERSATION",
"id": "100000000000039372",
"performed_time": {
"display_value": "Apr 6, 2023 04:35 PM",
"value": "1680779138803"
}
},
{
"performed_by": {
"email_id": "test1@zmail.com",
"is_technician": true,
"sms_mail": null,
"mobile": null,
"last_name": "test1",
"user_scope": "internal_user",
"sms_mail_id": null,
"site": {
"deleted": false,
"name": "Base Site",
"id": "100000000000006130",
"is_default": true
},
"phone": null,
"employee_id": null,
"name": "test",
"id": "100000000000036225",
"photo_url": "test-photo_url",
"is_vip_user": false,
"department": null,
"first_name": "test",
"job_title": null
},
"description": "dfgh",
"id": "100000000000039406",
"performed_time": {
"display_value": "Apr 6, 2023 04:42 PM",
"value": "1680779540061"
}
}
],
"response_status": [
{
"status_code": 2000,
"status": "success"
}
],
"list_info": {
"has_more_rows": false,
"row_count": 3
}
}
Delete Contract Note
Use this operation to delete a note from a contract
Url
<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}
$ curl <service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}\
-X DELETE\
-H "Accept: application/vnd.manageengine.sdp.v3+json"\
-H "Authorization: Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"\
-H "Content-Type: application/x-www-form-urlencoded"
// Deluge Sample script
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}";
headers = {"Accept":"application/vnd.manageengine.sdp.v3+json",
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"};
response = invokeurl
[
url: url
type: DELETE
headers: headers
];
info response;
#Powershell version - 5.1
$url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}"
$headers = @{ "Accept" = "application/vnd.manageengine.sdp.v3+json"
"Authorization" = "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"
"Content-Type" = "application/x-www-form-urlencoded"}
$response = Invoke-RestMethod -Uri $url -Method delete -Headers $headers
$response
#Python version - 3.10
from urllib.error import HTTPError
from urllib.request import urlopen,Request
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/{note_id}"
headers ={"Accept": "application/vnd.manageengine.sdp.v3+json",
"Authorization" : "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx",
"Content-Type" : "application/x-www-form-urlencoded"}
httprequest = Request(url, headers=headers,method="DELETE")
try:
with urlopen(httprequest) as response:
print(response.read().decode())
except HTTPError as e:
print(e.read().decode())
{
"response_status": {
"status_code": 2000,
"status": "success"
}
}
Upload Attachments To Notes
Use this operation to upload an attachment to the note
Mandatory Fields :- filename
Url
<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/_uploads
Attributes
filename (FILE)
The path of the file to be uploaded must be given with ’@’ at the beginning of the path.
addtoattachment (BOOLEAN)
Denotes whether to add the file as an attachment to the associated entity.
files (FILES)
The details of the file is contained here.
show attribute
size (LONG)
The size of the file that is uploaded.
content_type (STRING)
The type of the content of the file.
file_id (LONG)
The file_id is used to add that file as an attachment to the entity
$ curl <service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/_uploads \
-X POST\
-H "Accept: application/vnd.manageengine.sdp.v3+json"\
-H "Authorization: Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"\
-H "Content-Type: multipart/form-data"\
-F "filename=@local_file_path" -F "addtoattachment=true"\
// Deluge Sample script
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/_uploads ";
headers = {"Accept":"application/vnd.manageengine.sdp.v3+json",
"Content-Type": "multipart/form-data",
"Authorization": "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"};
file_list = List();
param1 = {"paramName":"filename", "content":"local_file_path"};
file_list.add(param1);
response = invokeurl
[
url: url
type: POST
headers: headers
files: file_list
];
info response;
#Powershell version - 5.1
$url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/_uploads "
$filePath = "local_file_path"
$addtoattachment = "true"
$boundary = [System.Guid]::NewGuid().ToString()
$headers = @{
"Accept" = "application/vnd.manageengine.sdp.v3+json"
"Authorization" = "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"
"Content-Type" = "multipart/form-data; boundary=`"$boundary`""
}
$content = [System.Text.Encoding]::GetEncoding('iso-8859-1').GetString([System.IO.File]::ReadAllBytes($filePath))
$body = (
"--$boundary",
"Content-Disposition: form-data; name=`"addtoattachment`"`r`n",
"$addtoattachment",
"--$boundary",
"Content-Disposition: form-data; name=`"filename`"; filename=`"$(Split-Path $filePath -Leaf)`"",
"Content-Type: $([System.Web.MimeMapping]::GetMimeMapping($filePath))`r`n",
$content,
"--$boundary--`r`n"
) -join "`r`n"
$response = Invoke-RestMethod -Uri $url -Method post -Headers $headers -Body $body
$response
#Python version - 3.10
from urllib.error import HTTPError
from urllib.request import Request,urlopen
import mimetypes
import ntpath
import uuid
url = "<service domain|custom domain>/app/<portal>/api/v3/contracts/{contract_id}/notes/_uploads "
file_path = "local_file_path"
add_to_attachments = "true"
boundary = uuid.uuid4()
headers = {
"Content-Type": f"multipart/form-data; boundary={boundary}",
"Accept": "application/vnd.manageengine.sdp.v3+json",
"Authorization": "Zoho-oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx",
}
with open(file_path, "rb") as f:
content = f.read()
body = (
bytes(f'--{boundary}\r\nContent-Disposition: form-data; name="addtoattachment"\r\n\r\n{add_to_attachments}\r\n', "utf-8")
+ bytes(f'--{boundary}\r\nContent-Disposition: form-data; name="filename"; filename="{ntpath.basename(file_path)}"\r\nContent-Type: {mimetypes.guess_type(file_path)[0] or "application/octet-stream"}\r\n\r\n', "utf-8")
+ content
+ bytes(f"\r\n--{boundary}--", "utf-8")
)
httprequest = Request(url, data=body, headers=headers)
try:
with urlopen(httprequest) as response:
print(response.read().decode("utf-8"))
except HTTPError as e:
print(e.read().decode())
{
"response_status": [
{
"status_code": 2000,
"status": "success"
}
],
"files": [
{
"content_type": "application/pdf",
"size": "119747",
"file_id": "1013",
"name": "samplepo.pdf",
"content_url": "/contracts/100000000000039185/notes/_uploads/1013"
}
]
}