Back to Collection Items
var
http: TChilkatHttp;
success: Integer;
req: TChilkatHttpRequest;
jsonFormData1: TChilkatJsonObject;
resp: IChilkatHttpResponse;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := TChilkatHttp.Create(Self);
req := TChilkatHttpRequest.Create(Self);
req.HttpVerb := 'PUT';
req.Path := '/v2.1/accounts/{{accountId}}/brands/{{brandId}}/resources/{{resourceContentType}}';
req.ContentType := 'multipart/form-data';
jsonFormData1 := TChilkatJsonObject.Create(Self);
req.AddStringForUpload2('file.xml','',jsonFormData1.ControlInterface,'utf-8','application/json');
req.AddHeader('Authorization','Bearer {{accessToken}}');
req.AddHeader('Accept','application/json');
resp := http.SynchronousRequest('domain.com',443,1,req.ControlInterface);
if (http.LastMethodSuccess = 0) then
begin
Memo1.Lines.Add(http.LastErrorText);
Exit;
end;
Memo1.Lines.Add(IntToStr(resp.StatusCode));
Memo1.Lines.Add(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}}",
"type": "string"
},
{
"key": "brandId",
"value": "{{brandId}}",
"type": "string"
},
{
"key": "resourceContentType",
"value": "{{resourceContentType}}",
"type": "string"
}
]
}
},
"response": [
]
}