Chilkat Online Tools

PowerBuilder / DocuSign Rooms API - v2 / Add a document to a room via file contents upload.

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_Resp

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Use this online tool to generate code from sample JSON: Generate Code to Create JSON

// The following JSON is sent in the request body.

// {}

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_Http.SetRequestHeader("Content-Type","multipart/form-data")
// Adds the "Authorization: Bearer {{accessToken}}" header.
loo_Http.AuthToken = "{{accessToken}}"
loo_Http.SetRequestHeader("Accept","text/plain, application/json, text/json")

loo_Resp = loo_Http.PostJson3("https://domain.com/v2/accounts/{{accountId}}/rooms/{{roomId}}/documents/contents","multipart/form-data",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Json
    return
end if

Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp


destroy loo_Http
destroy loo_Json

Curl Command

curl -X POST
	-H "Accept: text/plain, application/json, text/json"
	-H "Content-Type: multipart/form-data"
	-H "Authorization: Bearer {{accessToken}}"
	-d '{}'
https://domain.com/v2/accounts/{{accountId}}/rooms/{{roomId}}/documents/contents

Postman Collection Item JSON

{
  "name": "Add a document to a room via file contents upload.",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Accept",
        "value": "text/plain, application/json, text/json"
      },
      {
        "key": "Content-Type",
        "value": "multipart/form-data"
      },
      {
        "key": "Authorization",
        "value": "Bearer {{accessToken}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{}"
    },
    "url": {
      "raw": "{{baseUrl}}/v2/accounts/{{accountId}}/rooms/{{roomId}}/documents/contents",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "v2",
        "accounts",
        "{{accountId}}",
        "rooms",
        "{{roomId}}",
        "documents",
        "contents"
      ],
      "variable": [
        {
          "key": "roomId",
          "value": "{{roomId}}"
        },
        {
          "key": "accountId",
          "value": "{{accountId}}"
        }
      ]
    }
  },
  "response": [
  ]
}