Chilkat Online Tools

C# / DocuSign REST API / Uploads a branding resource file.

Back to Collection Items

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

Chilkat.Http http = new Chilkat.Http();
bool success;

Chilkat.HttpRequest req = new Chilkat.HttpRequest();
req.HttpVerb = "PUT";
req.Path = "/v2.1/accounts/{{accountId}}/brands/{{brandId}}/resources/{{resourceContentType}}";
req.ContentType = "multipart/form-data";

Chilkat.JsonObject jsonFormData1 = new Chilkat.JsonObject();
req.AddParam("file.xml",jsonFormData1.Emit());

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

Chilkat.HttpResponse resp = http.SynchronousRequest("domain.com",443,true,req);
if (http.LastMethodSuccess == false) {
    Debug.WriteLine(http.LastErrorText);
    return;
}

Debug.WriteLine(Convert.ToString(resp.StatusCode));
Debug.WriteLine(resp.BodyStr);

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