POST api/articles/images?articleNumber={articleNumber}&firstPrimary={firstPrimary}&replaceExisting={replaceExisting}
Uploads one or more article images using a multipart/form-data request.
Request Information
URI Parameters
| Name | Description | Type | Additional information |
|---|---|---|---|
| articleNumber |
Article number. |
integer |
Required |
| firstPrimary |
Indicates if the first image in the multipart content should be the primary image. |
boolean |
Required |
| replaceExisting |
Indicates if the images for the articles should be replaced (old images will be deleted and replaced by the images posted). |
boolean |
Required |
Body Parameters
None.
Remarks
Please be aware that images are stored with the name given by the client.
If the client sends the same name twice, the first image will be overwritten.
If the
Any existing primary image for the article will be replaced. This can be changed in article registry later.
Note that the images are uploaded as multipart content.
Only mime types "image/jpeg", "image/png", "image/gif" are supported.
Example
.NET C# example:
var client = new HttpClient();
client.BaseAddress = ddapiUri;
client.DefaultRequestHeaders.Authorization = new BasicAuthenticationHeaderValue(username, password);
client.DefaultRequestHeaders.Add("DDAPI-Origin", "Origin");
var mpd = new MultipartFormDataContent();
using (FileStream fs = new FileStream(Environment.CurrentDirectory + @"\Images\test.jpg", FileMode.Open))
{
using(var sc = new StreamContent(fs))
{
//mime type needs to be set depending on image type
sc.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/jpeg");
mpd.Add(sc, "test", "TestImage.jpg");
var response = await client.PostAsync($"/api/articles/images?articleNumber={articleNumber}&firstPrimary=true&replaceExisting=true", mpd);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
Response Information
Resource Description
A list of (AddArticleImageBankDataResult).
Collection of AddArticleImageBankDataResult| Name | Description | Type | Additional information |
|---|---|---|---|
| ArticleNumber | integer |
None. |
|
| ImageUrl | string |
None. |
|
| OriginalImageUrl | string |
None. |
|
| ThumbnailImageUrl | string |
None. |
|
| IsPrimary | boolean |
None. |
|
| Size | integer |
None. |
|
| Error | string |
None. |
Response Formats
application/json, text/json
[
{
"ArticleNumber": 1,
"ImageUrl": "sample string 2",
"OriginalImageUrl": "sample string 3",
"ThumbnailImageUrl": "sample string 4",
"IsPrimary": true,
"Size": 6,
"Error": "sample string 7"
},
{
"ArticleNumber": 1,
"ImageUrl": "sample string 2",
"OriginalImageUrl": "sample string 3",
"ThumbnailImageUrl": "sample string 4",
"IsPrimary": true,
"Size": 6,
"Error": "sample string 7"
}
]
application/xml, text/xml
<ArrayOfAddArticleImageBankDataResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Compilator.DDAPI.DTO.Article">
<AddArticleImageBankDataResult>
<ArticleNumber>1</ArticleNumber>
<Error>sample string 7</Error>
<ImageUrl>sample string 2</ImageUrl>
<IsPrimary>true</IsPrimary>
<OriginalImageUrl>sample string 3</OriginalImageUrl>
<Size>6</Size>
<ThumbnailImageUrl>sample string 4</ThumbnailImageUrl>
</AddArticleImageBankDataResult>
<AddArticleImageBankDataResult>
<ArticleNumber>1</ArticleNumber>
<Error>sample string 7</Error>
<ImageUrl>sample string 2</ImageUrl>
<IsPrimary>true</IsPrimary>
<OriginalImageUrl>sample string 3</OriginalImageUrl>
<Size>6</Size>
<ThumbnailImageUrl>sample string 4</ThumbnailImageUrl>
</AddArticleImageBankDataResult>
</ArrayOfAddArticleImageBankDataResult>