Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
loReq = createobject("CkHttpRequest")
loReq.HttpVerb = "POST"
loReq.Path = "/public/v1/documents/{{document_id}}/attachments/"
loReq.ContentType = "multipart/form-data"
llSuccess = loReq.AddFileForUpload2("file"," path to file","application/octet-stream")
loReq.AddHeader("Authorization","API-Key {{api_key}}")
loReq.AddHeader("Expect","100-continue")
loResp = loHttp.SynchronousRequest("api.pandadoc.com",443,.T.,loReq)
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loReq
return
endif
? str(loResp.StatusCode)
? loResp.BodyStr
release loResp
release loHttp
release loReq
Curl Command
curl -X POST
-H "Authorization: Bearer {{access_token}}"
-H "Authorization: API-Key {{api_key}}"
--form 'file=@"/path/to/file"'
https://api.pandadoc.com/public/v1/documents/{{document_id}}/attachments/
Postman Collection Item JSON
{
"name": "Create Attachment",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = JSON.parse(responseBody);",
"if (jsonData.uuid !== undefined) {",
" postman.setEnvironmentVariable(\"attachment_id\", jsonData.uuid);",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{access_token}}",
"type": "text",
"disabled": true
},
{
"key": "Authorization",
"value": "API-Key {{api_key}}",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": [
]
},
{
"key": "name",
"value": "File Test Name",
"type": "text",
"disabled": true
}
]
},
"url": {
"raw": "https://api.pandadoc.com/public/v1/documents/{{document_id}}/attachments/",
"protocol": "https",
"host": [
"api",
"pandadoc",
"com"
],
"path": [
"public",
"v1",
"documents",
"{{document_id}}",
"attachments",
""
]
}
},
"response": [
]
}