Chilkat Online Tools

Objective-C / DocuSign REST API / Adds/updates a user signature.

Back to Collection Items

#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoStringBuilder.h>
#import <CkoHttpResponse.h>

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

CkoHttp *http = [[CkoHttp alloc] init];
BOOL 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.

// {
//   "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"
//     }
//   ]
// }

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"userSignatures[0].signatureId" value: @"sample string 1"];
[json UpdateString: @"userSignatures[0].stampType" value: @"sample string 2"];
[json UpdateString: @"userSignatures[0].phoneticName" value: @"sample string 3"];
[json UpdateString: @"userSignatures[0].imageType" value: @"sample string 4"];
[json UpdateString: @"userSignatures[0].externalID" value: @"sample string 5"];
[json UpdateString: @"userSignatures[0].stampSizeMM" value: @"sample string 6"];
[json UpdateString: @"userSignatures[0].stampFormat" value: @"sample string 7"];
[json UpdateString: @"userSignatures[0].dateStampProperties.dateAreaX" value: @"sample string 1"];
[json UpdateString: @"userSignatures[0].dateStampProperties.dateAreaY" value: @"sample string 2"];
[json UpdateString: @"userSignatures[0].dateStampProperties.dateAreaWidth" value: @"sample string 3"];
[json UpdateString: @"userSignatures[0].dateStampProperties.dateAreaHeight" value: @"sample string 4"];
[json UpdateString: @"userSignatures[0].stampImageUri" value: @"sample string 8"];
[json UpdateString: @"userSignatures[0].signatureFont" value: @"sample string 9"];
[json UpdateString: @"userSignatures[0].signatureType" value: @"sample string 10"];
[json UpdateString: @"userSignatures[0].signatureName" value: @"sample string 11"];
[json UpdateString: @"userSignatures[0].signatureImageUri" value: @"sample string 12"];
[json UpdateString: @"userSignatures[0].signatureInitials" value: @"sample string 13"];
[json UpdateString: @"userSignatures[0].initialsImageUri" value: @"sample string 14"];
[json UpdateString: @"userSignatures[0].createdDateTime" value: @"sample string 15"];
[json UpdateString: @"userSignatures[0].adoptedDateTime" value: @"sample string 16"];
[json UpdateString: @"userSignatures[0].signature150ImageId" value: @"sample string 17"];
[json UpdateString: @"userSignatures[0].initials150ImageId" value: @"sample string 18"];

// Adds the "Authorization: Bearer {{accessToken}}" header.
http.AuthToken = @"{{accessToken}}";
[http SetRequestHeader: @"Accept" value: @"application/json"];

CkoStringBuilder *sbRequestBody = [[CkoStringBuilder alloc] init];
[json EmitSb: sbRequestBody];

CkoHttpResponse *resp = [http PTextSb: @"PUT" url: @"https://domain.com/v2.1/accounts/{{accountId}}/users/{{userId}}/signatures" textData: sbRequestBody charset: @"utf-8" contentType: @"application/json" md5: NO gzip: NO];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);

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": [
  ]
}