Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vReq
Handle hoReq
Variant vJsonFormData1
Handle hoJsonFormData1
Variant vJsonFormData2
Handle hoJsonFormData2
Variant vResp
Handle hoResp
String sTemp1
Integer iTemp1
Boolean bTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Get Create (RefClass(cComChilkatHttpRequest)) To hoReq
If (Not(IsComObjectCreated(hoReq))) Begin
Send CreateComObject of hoReq
End
Set ComHttpVerb Of hoReq To "POST"
Set ComPath Of hoReq To "/exchange/api/v1/assets"
Set ComContentType Of hoReq To "multipart/form-data"
Get Create (RefClass(cComChilkatJsonObject)) To hoJsonFormData1
If (Not(IsComObjectCreated(hoJsonFormData1))) Begin
Send CreateComObject of hoJsonFormData1
End
Get pvComObject of hoJsonFormData1 to vJsonFormData1
Get ComAddStringForUpload2 Of hoReq "organizationId" "" vJsonFormData1 "utf-8" "application/json" To iSuccess
Get Create (RefClass(cComChilkatJsonObject)) To hoJsonFormData2
If (Not(IsComObjectCreated(hoJsonFormData2))) Begin
Send CreateComObject of hoJsonFormData2
End
Get pvComObject of hoJsonFormData2 to vJsonFormData2
Get ComAddStringForUpload2 Of hoReq "groupId" "" vJsonFormData2 "utf-8" "application/json" To iSuccess
Send ComAddParam To hoReq "assetId" "{{organization_id}}{{organization_id}}mysoapapp"
Send ComAddParam To hoReq "version" "{{organization_id}}{{organization_id}}mysoapapp1.0.0"
Send ComAddParam To hoReq "{{organization_id}}{{organization_id}}mysoapapp1.0.0my soap app" ""
Send ComAddParam To hoReq "classifier" "{{organization_id}}{{organization_id}}mysoapapp1.0.0my soap appwsdl"
Send ComAddParam To hoReq "apiVersion" "{{organization_id}}{{organization_id}}mysoapapp1.0.0my soap appwsdlv1"
Get ComAddFileForUpload2 Of hoReq "asset" " path to file" "application/octet-stream" To iSuccess
Send ComAddHeader To hoReq "Authorization" "Bearer {{token}}"
Send ComAddHeader To hoReq "Expect" "100-continue"
Get pvComObject of hoReq to vReq
Get ComSynchronousRequest Of hoHttp "domain.com" 443 True vReq To vResp
If (IsComObject(vResp)) Begin
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
End
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
Showln iTemp1
Get ComBodyStr Of hoResp To sTemp1
Showln sTemp1
Send Destroy of hoResp
End_Procedure
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": [
]
}