Back to Collection Items
#include <CkHttp.h>
#include <CkHttpRequest.h>
#include <CkJsonObject.h>
#include <CkHttpResponse.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http;
bool success;
CkHttpRequest req;
req.put_HttpVerb("PUT");
req.put_Path("/v2.1/accounts/{{accountId}}/brands/{{brandId}}/resources/{{resourceContentType}}");
req.put_ContentType("multipart/form-data");
CkJsonObject jsonFormData1;
req.AddStringForUpload2("file.xml","",jsonFormData1,"utf-8","application/json");
req.AddHeader("Authorization","Bearer {{accessToken}}");
req.AddHeader("Accept","application/json");
CkHttpResponse *resp = http.SynchronousRequest("domain.com",443,true,req);
if (http.get_LastMethodSuccess() == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
std::cout << resp->get_StatusCode() << "\r\n";
std::cout << resp->bodyStr() << "\r\n";
delete resp;
}
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": [
]
}