Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_SbRequestBody
oleobject loo_Resp
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "first_name": "test1",
// "last_name": "test1",
// "company": "test1",
// "job_title": "test1",
// "phone": "test1",
// "country": "test1",
// "state": "test1",
// "street_address": "test1",
// "city": "test1",
// "postal_code": "test1"
// }
loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.UpdateString("first_name","test1")
loo_Json.UpdateString("last_name","test1")
loo_Json.UpdateString("company","test1")
loo_Json.UpdateString("job_title","test1")
loo_Json.UpdateString("phone","test1")
loo_Json.UpdateString("country","test1")
loo_Json.UpdateString("state","test1")
loo_Json.UpdateString("street_address","test1")
loo_Json.UpdateString("city","test1")
loo_Json.UpdateString("postal_code","test1")
// Adds the "Authorization: Bearer {{access_token}}" header.
loo_Http.AuthToken = "{{access_token}}"
loo_SbRequestBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Json.EmitSb(loo_SbRequestBody)
loo_Resp = loo_Http.PTextSb("PATCH","https://api.pandadoc.com/public/v1/contacts/{{contact_id}}/",loo_SbRequestBody,"utf-8","application/json",0,0)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
return
end if
Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
Curl Command
curl -X PATCH
-H "Authorization: API-Key {{api_key}}"
-H "Authorization: Bearer {{access_token}}"
-d '{
"first_name": "test1",
"last_name": "test1",
"company": "test1",
"job_title": "test1",
"phone": "test1",
"country":"test1",
"state":"test1",
"street_address":"test1",
"city":"test1",
"postal_code":"test1"
}'
https://api.pandadoc.com/public/v1/contacts/{{contact_id}}/
Postman Collection Item JSON
{
"name": "Update Contact",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PATCH",
"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 \"first_name\": \"test1\",\n \"last_name\": \"test1\",\n \"company\": \"test1\",\n \"job_title\": \"test1\",\n \"phone\": \"test1\",\n \"country\":\"test1\",\n \"state\":\"test1\",\n \"street_address\":\"test1\",\n \"city\":\"test1\",\n \"postal_code\":\"test1\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://api.pandadoc.com/public/v1/contacts/{{contact_id}}/",
"protocol": "https",
"host": [
"api",
"pandadoc",
"com"
],
"path": [
"public",
"v1",
"contacts",
"{{contact_id}}",
""
]
}
},
"response": [
]
}