Create image
Description
Create a new image
Important: this method uses the “multipart/form-data” format, because of file upload efficiency.
Consider reading our recommendations before populating your collection, it might help to improve the recognition latter on.
Url
1 |
POST /api/v0/image/ |
Parameters
optional
- item: resource uri like /v0/item/UUID/
- file: file with the new reference image
Example
Create an image (using local file back_cover.jpg) in the item whose UUID is 4fe672886ec142f6ab6d72d54acf046f
Request
HTTP Status code: 201 Created
1 2 3 4 |
curl -X POST 'https://my.craftar.net/api/v0/image/?api_key=123456789abcdefghijk123456789abcdefghijk' -F "item=/api/v0/item/4fe672886ec142f6ab6d72d54acf046f/" -F "file=@back_cover.jpg" |
Response
1 2 3 4 5 6 7 8 9 10 11 |
{ "uuid": "7c7540e0a6274accab95584235bb4e26", "file": "https://example.com/collections/440c374d09424243b9448cd289545db1/images/4fe672886ec142f6ab6d72d54acf046f_7c7540e0a6274accab95584235bb4e26", "item": "/api/v0/item/4fe672886ec142f6ab6d72d54acf046f/", "name": "back_cover.jpg", "resource_uri": "/api/v0/image/7c7540e0a6274accab95584235bb4e26/", "status": "OK", "thumb_120": "https://example.com/cache/collections/440c374d09424243b9448cd289545db1/images/4fe672886ec142f6ab6d72d54acf046f_7c7540e0a6274accab95584235bb4e26_thumb_120.jpe", "thumb_60": "https://example.com/cache/collections/440c374d09424243b9448cd289545db1/images/4fe672886ec142f6ab6d72d54acf046f_7c7540e0a6274accab95584235bb4e26_thumb_60.jpe", "tracking_data_status": "NO" } |
Errors
HTTP Status code: 400 Bad Request
POST data is not in multipart/form-data
1 2 3 4 5 6 |
{ "error": { "message": "Expected multipart/form-data content but got text/plain.", "code": "WRONG_CONTENT_TYPE" } } |
Item missing or not found
1 2 3 4 5 6 7 8 9 |
{ "error": { "message": "Some of the provided fields couldn't be validated. See the 'details' key for more information.", "code": "VALIDATION_ERROR", "details": { "item": ["This field is required."] } } } |
Invalid image
1 2 3 4 5 6 |
{ "error": { "message": "The image you provided couldn't be processed. Verify that it is a valid JPEG or PNG image and that it didn't get corrupted.", "code": "IMAGE_INVALID" } } |
Image too small
1 2 3 4 5 6 |
{ "error": { "message": "The image you provided is too small. Check the documentation on our website: http://docsupdated.wpengine.com/documentation/reference-image/", "code": "IMAGE_TOO_SMALL" } } |
HTTP Status code: 403 Forbidden
Image limit reached
1 2 3 4 5 6 |
{ "error": { "message": "You have reached the limit of images for your plan. You can upgrade to a bigger plan to increase this limit.", "code": "IMAGE_QUOTA_EXCEEDED" } } |
AR Item already has an image
1 2 3 4 5 6 |
{ "error": { "message": "Augmented reality items can have only one image. The image can be deleted only by deleting the item.", "code": "AR_ITEM_IMAGE_COUNT" } } |