Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
let req = CkoHttpRequest()!
req.httpVerb = "POST"
req.path = "/apimanager/api/v1/organizations/{{organization_id}}/environments/{{environment_id}}/apis"
req.contentType = "multipart/form-data"
success = req.addFile(forUpload2: "file", path: " path to file", contentType: "application/octet-stream")
req.addHeader("Authorization", value: "Bearer {{token}}")
req.addHeader("Expect", value: "100-continue")
var resp: CkoHttpResponse? = http.synchronousRequest("domain.com", port: 443, ssl: true, req: req)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
print("\(resp!.statusCode.intValue)")
print("\(resp!.bodyStr!)")
resp = nil
}
Curl Command
curl -X POST
-H "Authorization: Bearer {{token}}"
--form 'file=@"/path/to/file"'
https://domain.com/apimanager/api/v1/organizations/{{organization_id}}/environments/{{environment_id}}/apis
Postman Collection Item JSON
{
"name": "Import api as zip",
"protocolProfileBehavior": {
"disabledSystemHeaders": {}
},
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": "shop-locator-v1-16802092.zip"
}
]
},
"url": {
"raw": "{{url}}/apimanager/api/v1/organizations/{{organization_id}}/environments/{{environment_id}}/apis",
"host": [
"{{url}}"
],
"path": [
"apimanager",
"api",
"v1",
"organizations",
"{{organization_id}}",
"environments",
"{{environment_id}}",
"apis"
]
}
},
"response": [
]
}