Back to Collection Items
var os = require('os');
if (os.platform() == 'win32') {
if (os.arch() == 'ia32') {
var chilkat = require('@chilkat/ck-node21-win-ia32');
} else {
var chilkat = require('@chilkat/ck-node21-win64');
}
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('@chilkat/ck-node21-arm');
} else if (os.arch() == 'x86') {
var chilkat = require('@chilkat/ck-node21-linux32');
} else {
var chilkat = require('@chilkat/ck-node21-linux64');
}
} else if (os.platform() == 'darwin') {
if (os.arch() == 'arm64') {
var chilkat = require('@chilkat/ck-node21-mac-m1');
} else {
var chilkat = require('@chilkat/ck-node21-macosx');
}
}
function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new chilkat.Http();
var success;
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "email": "nobody@example.com",
// "first_name": "test",
// "last_name": "test",
// "company": "test",
// "job_title": "test",
// "phone": "test",
// "country": "test",
// "state": "test",
// "street_address": "test",
// "city": "test",
// "postal_code": "test"
// }
var json = new chilkat.JsonObject();
json.UpdateString("email","nobody@example.com");
json.UpdateString("first_name","test");
json.UpdateString("last_name","test");
json.UpdateString("company","test");
json.UpdateString("job_title","test");
json.UpdateString("phone","test");
json.UpdateString("country","test");
json.UpdateString("state","test");
json.UpdateString("street_address","test");
json.UpdateString("city","test");
json.UpdateString("postal_code","test");
// Adds the "Authorization: Bearer {{access_token}}" header.
http.AuthToken = "{{access_token}}";
// resp: HttpResponse
var resp = http.PostJson3("https://api.pandadoc.com/public/v1/contacts/","application/json",json);
if (http.LastMethodSuccess == false) {
console.log(http.LastErrorText);
return;
}
console.log(resp.StatusCode);
console.log(resp.BodyStr);
}
chilkatExample();
Curl Command
curl -X POST
-H "Authorization: API-Key {{api_key}}"
-H "Authorization: Bearer {{access_token}}"
-d '{
"email": "nobody@example.com",
"first_name": "test",
"last_name": "test",
"company": "test",
"job_title": "test",
"phone": "test",
"country":"test",
"state":"test",
"street_address":"test",
"city":"test",
"postal_code":"test"
}'
https://api.pandadoc.com/public/v1/contacts/
Postman Collection Item JSON
{
"name": "Create Contact",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = JSON.parse(responseBody);",
"if (jsonData.id !== undefined) {",
" postman.setEnvironmentVariable(\"contact_id\", jsonData.id);",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "API-Key {{api_key}}",
"type": "text"
},
{
"key": "Authorization",
"value": "Bearer {{access_token}}",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"nobody@example.com\",\n \"first_name\": \"test\",\n \"last_name\": \"test\",\n \"company\": \"test\",\n \"job_title\": \"test\",\n \"phone\": \"test\",\n \"country\":\"test\",\n \"state\":\"test\",\n \"street_address\":\"test\",\n \"city\":\"test\",\n \"postal_code\":\"test\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://api.pandadoc.com/public/v1/contacts/",
"protocol": "https",
"host": [
"api",
"pandadoc",
"com"
],
"path": [
"public",
"v1",
"contacts",
""
]
}
},
"response": [
]
}