Chilkat Online Tools

Perl / DocuSign REST API / Uploads a branding resource file.

Back to Collection Items

use chilkat();

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

$http = chilkat::CkHttp->new();

$req = chilkat::CkHttpRequest->new();
$req->put_HttpVerb("PUT");
$req->put_Path("/v2.1/accounts/{{accountId}}/brands/{{brandId}}/resources/{{resourceContentType}}");
$req->put_ContentType("multipart/form-data");

$jsonFormData1 = chilkat::CkJsonObject->new();
$req->AddParam("file.xml",$jsonFormData1->emit());

$req->AddHeader("Authorization","Bearer {{accessToken}}");
$req->AddHeader("Accept","application/json");

# resp is a HttpResponse
$resp = $http->SynchronousRequest("domain.com",443,1,$req);
if ($http->get_LastMethodSuccess() == 0) {
    print $http->lastErrorText() . "\r\n";
    exit;
}

print $resp->get_StatusCode() . "\r\n";
print $resp->bodyStr() . "\r\n";

Curl Command

curl -X PUT
	-H "Accept: application/json"
	-H "Content-Type: multipart/form-data"
	-H "Authorization: Bearer {{accessToken}}"
	--form 'file.xml={{file.xml}}'
https://domain.com/v2.1/accounts/{{accountId}}/brands/{{brandId}}/resources/{{resourceContentType}}

Postman Collection Item JSON

{
  "name": "Uploads a branding resource file.",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      },
      {
        "key": "Content-Type",
        "value": "multipart/form-data"
      },
      {
        "key": "Authorization",
        "value": "Bearer {{accessToken}}"
      }
    ],
    "body": {
      "mode": "formdata",
      "formdata": [
        {
          "key": "file.xml",
          "value": "{{file.xml}}",
          "type": "text"
        }
      ]
    },
    "url": {
      "raw": "{{baseUrl}}/v2.1/accounts/{{accountId}}/brands/{{brandId}}/resources/{{resourceContentType}}",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "v2.1",
        "accounts",
        "{{accountId}}",
        "brands",
        "{{brandId}}",
        "resources",
        "{{resourceContentType}}"
      ],
      "variable": [
        {
          "key": "accountId",
          "value": "{{accountId}}"
        },
        {
          "key": "brandId",
          "value": "{{brandId}}"
        },
        {
          "key": "resourceContentType",
          "value": "{{resourceContentType}}"
        }
      ]
    }
  },
  "response": [
  ]
}