Create item
Description
Create a new item
Url
1 |
POST /api/v0/item/ |
Parameters
optional
- name: string that describes the item
- collection: resource uri like /api/v0/collection/UUID/
- tags: list of resource URIs like ["/api/v0/tag/UUID1/", "/api/v0/tag/UUID2/"]
- url: URL related to the item's content
- content: a valid JSON object
- custom: any type of custom data attached to the item.
- trackable: true for creating an AR item (default: false)
Example
Create a Item with a url
Request
1 2 3 4 5 6 |
curl -X POST \ -H "Content-Type: application/json" \ 'https://my.craftar.net/api/v0/item/?api_key=123456789abcdefghijk123456789abcdefghijk' \ -d '{"collection": "/api/v0/collection/806e54535ffd464f83545c902e664aca/", "name": "The birth of venus", "url": "http://en.wikipedia.org/wiki/The_Birth_of_Venus_(Botticelli)" }' |
Response
HTTP Status code: 201 Created
1 2 3 4 5 6 7 8 |
{ "uuid": "c37fbdaf74bd46aa9f6b4ca60444d45b", "url": "http://en.wikipedia.org/wiki/The_Birth_of_Venus_(Botticelli)", "resource_uri": "/api/v0/item/c37fbdaf74bd46aa9f6b4ca60444d45b/", "name": "The birth of venus", "content": null, "collection": "/api/v0/collection/806e54535ffd464f83545c902e664aca/" } |
Create a trackable Item with content
Request
1 2 3 4 5 6 7 |
curl -X POST \ -H "Content-Type: application/json" \ 'https://my.craftar.net/api/v0/item/?api_key=123456789abcdefghijk123456789abcdefghijk' \ -d '{"collection": "/api/v0/collection/806e54535ffd464f83545c902e664aca/", "name": "The Scream", "trackable": true, "content": {"year": 1893, "artist": "Edvard Munch"} }' |
Response
HTTP Status code: 201 Created
1 2 3 4 5 6 7 8 9 |
{ "uuid": "0b49bec91a3d49e7971351ff358456a6", "url": "", "trackable": true, "resource_uri": "/api/v0/item/0b49bec91a3d49e7971351ff358456a6/", "name": "The Scream", "content": "{u'artist': u'Edvard Munch', u'year': 1893}", "collection": "/api/v0/collection/806e54535ffd464f83545c902e664aca/" } |
Errors
HTTP Status code: 400 Bad Request
Invalid JSON
1 2 3 4 5 6 |
{ "error": { "message": "The content is not a valid JSON document.", "code": "INVALID_JSON" } } |
Content not in JSON
1 2 3 4 5 6 |
{ "error": { "message": "Expected application/json content but got application/xml.", "code": "WRONG_CONTENT_TYPE" } } |
Collection not found
1 2 3 4 5 6 7 8 9 |
{ "error": { "code": "VALIDATION_ERROR", "message": "Some of the provided fields couldn't be validated. See the 'details' key for more information.", "details": { "collection": ["This field is required."] } } } |
Empty item name
1 2 3 4 5 6 7 8 9 |
{ "error": { "code": "VALIDATION_ERROR", "message": "Some of the provided fields couldn't be validated. See the 'details' key for more information.", "details": { "name": ["This field is required."] } } } |