Chilkat Online Tools

lianja / 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.

loHttp = createobject("CkHttp")

loReq = createobject("CkHttpRequest")
loReq.HttpVerb = "PUT"
loReq.Path = "/v2.1/accounts/{{accountId}}/brands/{{brandId}}/resources/{{resourceContentType}}"
loReq.ContentType = "multipart/form-data"

loJsonFormData1 = createobject("CkJsonObject")
loReq.AddStringForUpload2("file.xml","",loJsonFormData1,"utf-8","application/json")

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

loResp = loHttp.SynchronousRequest("domain.com",443,.T.,loReq)
if (loHttp.LastMethodSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loReq
    release loJsonFormData1
    return
endif

? str(loResp.StatusCode)
? loResp.BodyStr
release loResp


release loHttp
release loReq
release loJsonFormData1

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