Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loReq
LOCAL loResp
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
loHttp.BasicAuth = 1
loHttp.Login = "{{webservice_key}}"
loHttp.Password = "password"
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.HttpRequest')
loReq = CreateObject('Chilkat.HttpRequest')
loReq.HttpVerb = "POST"
loReq.Path = "/api/images/products/1"
loReq.ContentType = "multipart/form-data"
lnSuccess = loReq.AddFileForUpload2("image"," path to file","application/octet-stream")
loReq.AddHeader("Expect","100-continue")
loResp = loHttp.SynchronousRequest("localhost",8080,1,loReq)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loReq
CANCEL
ENDIF
? STR(loResp.StatusCode)
? loResp.BodyStr
RELEASE loResp
RELEASE loHttp
RELEASE loReq
Curl Command
curl -X POST
-u '{{webservice_key}}:password'
-H "Content-Type: application/json"
--form 'image=@"/path/to/file"'
https://localhost:8080/api/images/products/1
Postman Collection Item JSON
{
"name": "6 - Upload image",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "image",
"type": "file",
"src": [
]
}
]
},
"url": {
"raw": "{{webservice_url}}/api/images/products/{{product_id}}",
"host": [
"{{webservice_url}}"
],
"path": [
"api",
"images",
"products",
"{{product_id}}"
]
}
},
"response": [
]
}