create_product_asset
POST https://api.bootic.net/v1/products/{product_id}/assets
Create a product asset, including uploading image data.
This relation is only available for products owned by your current access token (admin
scope).
HTTP POST
$ curl -XPOST -H'Accept:application/json' -H'Content-Type:application/json' -H "Authorization: Bearer xxxx" -i https://api.bootic.net/v1/products/:product_id/assets -d[REQUEST_BODY]
Request body
{
"file_name": "my-image.jpg",
"data": "[base64 data here]",
"title": "An image",
"description": "An optional description"
}
- file_name
- Asset file name, including extension. Required.
- data
- File data, base64-encoded. Optionally in base 64 Data URI format. Required.
- title
- Asset title. Optional.
- description
- Asset description. Optional.
- position
- Asset position in the list. Optional. Defaults to last position. Negative values insert from the last position. Ex. -2 inserts second to last.
Successful response
Status: 201 Created
Content-Type: application/json; charset=utf-8
Connection: keep-alive
ETag: "0728e2965bd03e20a7f1c33add2f8775"
Last-Modified: Fri, 20 Jun 2014 22:34:14 GMT
Cache-Control: must-revalidate, private, max-age=0
Date: Wed, 31 Jul 2013 21:11:52 GMT
X-OAuth-Scopes: admin
{
"_class": [
"image",
"asset"
],
"_links": {
"thumbnail": {
"href": "https://r.btcdn.co/47/thumbnail/123-foobar.jpg"
},
"small": {
"href": "https://r.btcdn.co/47/small/123-foobar.jpg"
},
"medium": {
"href": "https://r.btcdn.co/47/medium/123-foobar.jpg"
},
"large": {
"href": "https://r.btcdn.co/47/large/123-foobar.jpg"
},
"original": {
"href": "https://r.btcdn.co/47/original/123-foobar.jpg"
},
"btc:delete_product_asset": {
"href": "https://api.bootic.net/v1/products/65930/assets/123",
"method": "delete",
"title": "Delete a product image"
}
},
"file_name": "my-image.jpg",
"title": "An image",
"description": "An optional description"
}
A succesful response returns a product asset entity including links to predefined image sizes and further actions.
See delete_product_asset for more.
Invalid response
Status: 422 Unprocessable Entity
Content-Type: application/json; charset=utf-8
Connection: keep-alive
ETag: "0728e2965bd03e20a7f1c33add2f8775"
Last-Modified: Fri, 20 Jun 2014 22:34:14 GMT
Cache-Control: must-revalidate, private, max-age=0
Date: Wed, 31 Jul 2013 21:11:52 GMT
X-OAuth-Scopes: admin
{
"_class": [
"errors"
],
"_embedded": {
"errors": [
{
"_class": [
"error"
],
"field": "data",
"messages": [
"can't be blank"
]
}
]
}
}
Related content
Do you use Ruby? Checkout the Ruby tutorial on uploading product images from a directory.