Create an attachment
1 min
POST
https://api.campaign.episerver.net/rest/{clientId}/attachments
Path Parameters
- clientIdstringrequiredDescription
Header Parameters
- acceptstringDescriptionDefaultapplication/jsonAllowedapplication/jsonapplication/vnd.optivo.broadmail.v1+json
Form Parameters
- filestring<binary>requiredDescriptionFormatbinary
- namestringDescription
Responses
201
- RestAttachment
- idinteger<int64>DescriptionFormatint64
- ownerinteger<int64>DescriptionFormatint64
- namestringDescription
- uploadedbooleanDescription
- fileNamestringDescription
- typestringDescription
- mimeTypestringDescription
- sizeinteger<int64>DescriptionFormatint64
- createdstring<date-time>DescriptionFormatdate-time
- modifiedstring<date-time>DescriptionFormatdate-time
- linksobject[]
- uriBuilderobject
- relsstring[]
- relstring
- typestring
- paramsmap<string, string>
- titlestring
- uristring<uri>Formaturi
400
curl
curl --request POST \
--url https://api.campaign.episerver.net/rest/{clientId}/attachments \
--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}/attachments", 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}/attachments")
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}/attachments"
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 attachment was created successfully.
{
"id": "",
"owner": "",
"name": "",
"uploaded": false,
"fileName": "",
"type": "",
"mimeType": "",
"size": "",
"created": "",
"modified": "",
"links": [
{
"uriBuilder": {},
"rels": [
""
],
"rel": "",
"type": "",
"params": "",
"title": "",
"uri": ""
}
]
}400
// The parameters "name" and "file" are required or the file name has an invalid extension. Ensure that "name" and "file" parameters are added to the request and the file extension is correct.