Upload an image
1 min
POST
https://api.campaign.episerver.net/rest/{clientId}/assets/images
Path Parameters
- clientIdstringrequiredDescription
Header Parameters
- acceptstringDescriptionDefaultapplication/jsonAllowedapplication/jsonapplication/vnd.optivo.broadmail.v1+json
Form Parameters
- filestring<binary>requiredDescriptionFormatbinary
- namestringDescription
Responses
201
- RestImage
- idinteger<int64>DescriptionFormatint64
- ownerstringDescription
- namestringDescription
- urlstringDescription
- heightinteger<int32>DescriptionFormatint32
- widthinteger<int32>DescriptionFormatint32
- linksobject[]
- uriBuilderobject
- relsstring[]
- relstring
- typestring
- paramsmap<string, string>
- titlestring
- uristring<uri>Formaturi
400
500
curl
curl --request POST \
--url https://api.campaign.episerver.net/rest/{clientId}/assets/images \
--header 'accept: application/json' \
--header 'content-type: multipart/form-data' \
--form 'file=@"/path/to/file"'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "multipart/form-data");
var formdata = new FormData();
formdata.append("file", fileInput.files[0], "file");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: formdata,
redirect: 'follow'
};
fetch("https://api.campaign.episerver.net/rest/{clientId}/assets/images", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "net/http"
url = URI("https://api.campaign.episerver.net/rest/{clientId}/assets/images")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["content-type"] = "multipart/form-data"
form_data = [['file', File.open('/path/to/file')]]
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body
python
import requests
url = "https://api.campaign.episerver.net/rest/{clientId}/assets/images"
payload = {}
files=[
('file',('file',open('/path/to/file','rb'),'application/octet-stream'))
]
headers = {
'accept': 'application/json',
'content-type': 'multipart/form-data'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
201
// The image was uploaded successfully.
{
"id": "",
"owner": "",
"name": "",
"url": "",
"height": "",
"width": "",
"links": [
{
"uriBuilder": {},
"rels": [
""
],
"rel": "",
"type": "",
"params": "",
"title": "",
"uri": ""
}
]
}400
// The parameters "name" or "url" are both provided or not provided, or the file name is missing. Alternatively, the image content type is not one of [image/jpeg, image/png, image/gif]
500
// Error occurred while uploading the image.