Back to Collection Items
var
http: HCkHttp;
success: Boolean;
req: HCkHttpRequest;
jsonFormData1: HCkJsonObject;
jsonFormData2: HCkJsonObject;
resp: HCkHttpResponse;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := CkHttp_Create();
req := CkHttpRequest_Create();
CkHttpRequest_putHttpVerb(req,'POST');
CkHttpRequest_putPath(req,'/exchange/api/v1/assets');
CkHttpRequest_putContentType(req,'multipart/form-data');
jsonFormData1 := CkJsonObject_Create();
CkHttpRequest_AddStringForUpload2(req,'organizationId','',jsonFormData1,'utf-8','application/json');
jsonFormData2 := CkJsonObject_Create();
CkHttpRequest_AddStringForUpload2(req,'groupId','',jsonFormData2,'utf-8','application/json');
CkHttpRequest_AddParam(req,'assetId','{{organization_id}}{{organization_id}}mysoapapp');
CkHttpRequest_AddParam(req,'version','{{organization_id}}{{organization_id}}mysoapapp1.0.0');
CkHttpRequest_AddParam(req,'{{organization_id}}{{organization_id}}mysoapapp1.0.0my soap app','');
CkHttpRequest_AddParam(req,'classifier','{{organization_id}}{{organization_id}}mysoapapp1.0.0my soap appwsdl');
CkHttpRequest_AddParam(req,'apiVersion','{{organization_id}}{{organization_id}}mysoapapp1.0.0my soap appwsdlv1');
success := CkHttpRequest_AddFileForUpload2(req,'asset',' path to file','application/octet-stream');
CkHttpRequest_AddHeader(req,'Authorization','Bearer {{token}}');
CkHttpRequest_AddHeader(req,'Expect','100-continue');
resp := CkHttp_SynchronousRequest(http,'domain.com',443,True,req);
if (CkHttp_getLastMethodSuccess(http) = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
Memo1.Lines.Add(IntToStr(CkHttpResponse_getStatusCode(resp)));
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkHttpRequest_Dispose(req);
CkJsonObject_Dispose(jsonFormData1);
CkJsonObject_Dispose(jsonFormData2);
Curl Command
curl -X POST
-H "Authorization: Bearer {{token}}"
--form 'organizationId={{organization_id}}'
--form 'groupId={{organization_id}}{{organization_id}}'
--form 'assetId={{organization_id}}{{organization_id}}mysoapapp'
--form 'version={{organization_id}}{{organization_id}}mysoapapp1.0.0'
--form 'name={{organization_id}}{{organization_id}}mysoapapp1.0.0my soap app'
--form 'classifier={{organization_id}}{{organization_id}}mysoapapp1.0.0my soap appwsdl'
--form 'apiVersion={{organization_id}}{{organization_id}}mysoapapp1.0.0my soap appwsdlv1'
--form 'asset=@"/path/to/file"'
https://domain.com/exchange/api/v1/assets
Postman Collection Item JSON
{
"name": "Publish new asset on exchange",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "organizationId",
"value": "{{organization_id}}",
"type": "text"
},
{
"key": "groupId",
"value": "{{organization_id}}",
"type": "text"
},
{
"key": "assetId",
"value": "mysoapapp",
"type": "text"
},
{
"key": "version",
"value": "1.0.0",
"type": "text"
},
{
"key": "name",
"value": "my soap app",
"type": "text"
},
{
"key": "classifier",
"value": "wsdl",
"type": "text"
},
{
"key": "apiVersion",
"value": "v1",
"type": "text"
},
{
"key": "asset",
"type": "file",
"src": "/C:/Users/khanamir/Downloads/tshirts.demos.mulesoft.com.wsdl"
}
]
},
"url": {
"raw": "{{url}}/exchange/api/v1/assets",
"host": [
"{{url}}"
],
"path": [
"exchange",
"api",
"v1",
"assets"
]
}
},
"response": [
]
}