PureBasic / DocuSign REST API / Uploads a branding resource file.
Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttpRequest.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
req.i = CkHttpRequest::ckCreate()
If req.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttpRequest::setCkHttpVerb(req, "PUT")
CkHttpRequest::setCkPath(req, "/v2.1/accounts/{{accountId}}/brands/{{brandId}}/resources/{{resourceContentType}}")
CkHttpRequest::setCkContentType(req, "multipart/form-data")
jsonFormData1.i = CkJsonObject::ckCreate()
If jsonFormData1.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttpRequest::ckAddStringForUpload2(req,"file.xml","",jsonFormData1,"utf-8","application/json")
CkHttpRequest::ckAddHeader(req,"Authorization","Bearer {{accessToken}}")
CkHttpRequest::ckAddHeader(req,"Accept","application/json")
resp.i = CkHttp::ckSynchronousRequest(http,"domain.com",443,1,req)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkHttpRequest::ckDispose(req)
CkJsonObject::ckDispose(jsonFormData1)
ProcedureReturn
EndIf
Debug Str(CkHttpResponse::ckStatusCode(resp))
Debug CkHttpResponse::ckBodyStr(resp)
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkHttpRequest::ckDispose(req)
CkJsonObject::ckDispose(jsonFormData1)
ProcedureReturn
EndProcedure
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": [
]
}