PureBasic / DocuSign REST API / Adds/updates a user signature.
Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; Use this online tool to generate code from sample JSON: Generate Code to Create JSON
; The following JSON is sent in the request body.
; {
; "userSignatures": [
; {
; "signatureId": "sample string 1",
; "stampType": "sample string 2",
; "phoneticName": "sample string 3",
; "imageType": "sample string 4",
; "externalID": "sample string 5",
; "stampSizeMM": "sample string 6",
; "stampFormat": "sample string 7",
; "dateStampProperties": {
; "dateAreaX": "sample string 1",
; "dateAreaY": "sample string 2",
; "dateAreaWidth": "sample string 3",
; "dateAreaHeight": "sample string 4"
; },
; "stampImageUri": "sample string 8",
; "signatureFont": "sample string 9",
; "signatureType": "sample string 10",
; "signatureName": "sample string 11",
; "signatureImageUri": "sample string 12",
; "signatureInitials": "sample string 13",
; "initialsImageUri": "sample string 14",
; "createdDateTime": "sample string 15",
; "adoptedDateTime": "sample string 16",
; "signature150ImageId": "sample string 17",
; "initials150ImageId": "sample string 18"
; }
; ]
; }
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckUpdateString(json,"userSignatures[0].signatureId","sample string 1")
CkJsonObject::ckUpdateString(json,"userSignatures[0].stampType","sample string 2")
CkJsonObject::ckUpdateString(json,"userSignatures[0].phoneticName","sample string 3")
CkJsonObject::ckUpdateString(json,"userSignatures[0].imageType","sample string 4")
CkJsonObject::ckUpdateString(json,"userSignatures[0].externalID","sample string 5")
CkJsonObject::ckUpdateString(json,"userSignatures[0].stampSizeMM","sample string 6")
CkJsonObject::ckUpdateString(json,"userSignatures[0].stampFormat","sample string 7")
CkJsonObject::ckUpdateString(json,"userSignatures[0].dateStampProperties.dateAreaX","sample string 1")
CkJsonObject::ckUpdateString(json,"userSignatures[0].dateStampProperties.dateAreaY","sample string 2")
CkJsonObject::ckUpdateString(json,"userSignatures[0].dateStampProperties.dateAreaWidth","sample string 3")
CkJsonObject::ckUpdateString(json,"userSignatures[0].dateStampProperties.dateAreaHeight","sample string 4")
CkJsonObject::ckUpdateString(json,"userSignatures[0].stampImageUri","sample string 8")
CkJsonObject::ckUpdateString(json,"userSignatures[0].signatureFont","sample string 9")
CkJsonObject::ckUpdateString(json,"userSignatures[0].signatureType","sample string 10")
CkJsonObject::ckUpdateString(json,"userSignatures[0].signatureName","sample string 11")
CkJsonObject::ckUpdateString(json,"userSignatures[0].signatureImageUri","sample string 12")
CkJsonObject::ckUpdateString(json,"userSignatures[0].signatureInitials","sample string 13")
CkJsonObject::ckUpdateString(json,"userSignatures[0].initialsImageUri","sample string 14")
CkJsonObject::ckUpdateString(json,"userSignatures[0].createdDateTime","sample string 15")
CkJsonObject::ckUpdateString(json,"userSignatures[0].adoptedDateTime","sample string 16")
CkJsonObject::ckUpdateString(json,"userSignatures[0].signature150ImageId","sample string 17")
CkJsonObject::ckUpdateString(json,"userSignatures[0].initials150ImageId","sample string 18")
; Adds the "Authorization: Bearer {{accessToken}}" header.
CkHttp::setCkAuthToken(http, "{{accessToken}}")
CkHttp::ckSetRequestHeader(http,"Accept","application/json")
sbRequestBody.i = CkStringBuilder::ckCreate()
If sbRequestBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckEmitSb(json,sbRequestBody)
resp.i = CkHttp::ckPTextSb(http,"PUT","https://domain.com/v2.1/accounts/{{accountId}}/users/{{userId}}/signatures",sbRequestBody,"utf-8","application/json",0,0)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
ProcedureReturn
EndIf
Debug Str(CkHttpResponse::ckStatusCode(resp))
Debug CkHttpResponse::ckBodyStr(resp)
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
ProcedureReturn
EndProcedure
Curl Command
curl -X PUT
-H "Accept: application/json"
-H "Authorization: Bearer {{accessToken}}"
-d '{
"userSignatures": [
{
"signatureId": "sample string 1",
"stampType": "sample string 2",
"phoneticName": "sample string 3",
"imageType": "sample string 4",
"externalID": "sample string 5",
"stampSizeMM": "sample string 6",
"stampFormat": "sample string 7",
"dateStampProperties": {
"dateAreaX": "sample string 1",
"dateAreaY": "sample string 2",
"dateAreaWidth": "sample string 3",
"dateAreaHeight": "sample string 4"
},
"stampImageUri": "sample string 8",
"signatureFont": "sample string 9",
"signatureType": "sample string 10",
"signatureName": "sample string 11",
"signatureImageUri": "sample string 12",
"signatureInitials": "sample string 13",
"initialsImageUri": "sample string 14",
"createdDateTime": "sample string 15",
"adoptedDateTime": "sample string 16",
"signature150ImageId": "sample string 17",
"initials150ImageId": "sample string 18"
}
]
}'
https://domain.com/v2.1/accounts/{{accountId}}/users/{{userId}}/signatures
Postman Collection Item JSON
{
"name": "Adds/updates a user signature.",
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{accessToken}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"userSignatures\": [\n {\n \"signatureId\": \"sample string 1\",\n \"stampType\": \"sample string 2\",\n \"phoneticName\": \"sample string 3\",\n \"imageType\": \"sample string 4\",\n \"externalID\": \"sample string 5\",\n \"stampSizeMM\": \"sample string 6\",\n \"stampFormat\": \"sample string 7\",\n \"dateStampProperties\": {\n \"dateAreaX\": \"sample string 1\",\n \"dateAreaY\": \"sample string 2\",\n \"dateAreaWidth\": \"sample string 3\",\n \"dateAreaHeight\": \"sample string 4\"\n },\n \"stampImageUri\": \"sample string 8\",\n \"signatureFont\": \"sample string 9\",\n \"signatureType\": \"sample string 10\",\n \"signatureName\": \"sample string 11\",\n \"signatureImageUri\": \"sample string 12\",\n \"signatureInitials\": \"sample string 13\",\n \"initialsImageUri\": \"sample string 14\",\n \"createdDateTime\": \"sample string 15\",\n \"adoptedDateTime\": \"sample string 16\",\n \"signature150ImageId\": \"sample string 17\",\n \"initials150ImageId\": \"sample string 18\"\n }\n ]\n}"
},
"url": {
"raw": "{{baseUrl}}/v2.1/accounts/{{accountId}}/users/{{userId}}/signatures",
"host": [
"{{baseUrl}}"
],
"path": [
"v2.1",
"accounts",
"{{accountId}}",
"users",
"{{userId}}",
"signatures"
],
"variable": [
{
"key": "accountId",
"value": "{{accountId}}"
},
{
"key": "userId",
"value": "{{userId}}"
}
]
}
},
"response": [
]
}