- Endpoint URL:
https://api.osbn.io/v1/postimages.php
- HTTP Method: POST
- Headers:
- Authorization: {token}
- OSBN: {OSBN}
- Testing: true
- Multipart/Form Parameters:
- cover_image or cover_url, author_image or author_url
Description:
The postimages REST API endpoint allows you to update an existing OSBN record with image data by making a POST request.
Notes:
- The OSBN record must already exist.
- At least one of cover_image or cover_url, author_image or author_url must be specified.
- Specifying Content-Type is unnecessary and not recommended. cURL has already set the Content-Type to multipart/form-data due to the presence of -F.
- If the user specifies the same filetype twice (for example, a cover_image and a cover_image again), then the second will be used.
- If the user specifies the same type twice (for example, a cover_image and a cover_url), then the URL will be used.
- Acceptable image format for files are: jpg, png, gif, and webp.
- Maximum file size is: 256kB.
Request Parameters:
- Authorization (Header): The authorization header is used to authenticate the request. You should include a valid token to access the API.
- OSBN (Header): The OSBN to update in expanded format. (for example, OSBN-01-001-000001-001-4)
- Optional: Testing (Header): If set, then the OSBN record isn't altered.
and at least one of the below is required:
- cover_image (Data) string: path/filename to the cover image file on disk.
- cover_url (Data) string: The URL of the cover image.
- author_image (Data) string: path/filename to the author image file on disk.
- author_url (Data) string: The URL of the author image.
Deleting existing cover/author images:
- To delete image data, specify a dot "
.
" instead of an image file or URL.
-F "cover_url=."
will delete both a cover URL or a cover FILE, if it exists.
-F "author_image=@."
will delete both an author URL or an author FILE, if it exists.
Example 1: cURL Command:
curl -X POST https://api.osbn.io/v1/postimages.php \
-H "Authorization: Wmp6ADsd8PtWfMODoaYMXNHIjhHA5Ws" \
-H "OSBN: OSBN-01-001-000001-001-4" \
-F "cover_url=https://arnehemingway.com/books/TheBookOfArne/TheBookOfArneCoverBespoke.jpg"
Example 2: cURL Command:
curl -X POST https://api.osbn.io/v1/postimages.php \
-H "Authorization: Wmp6ADsd8PtWfMODoaYMXNHIjhHA5Ws" \
-H "OSBN: OSBN-01-001-000001-001-4" \
-F "author_image=@/home/arne/Pictures/Arne unshaven rugged handsome.jpg" \
-F "cover_url=https://arnehemingway.com/books/TheBookOfArne/TheBookOfArneCoverBespoke.jpg"
Example 3: cURL Command: (test mode, one line)
curl -X POST https://api.osbn.io/v1/postimages.php
-H "Authorization: Wmp6ADsd8PtWfMODoaYMXNHIjhHA5Ws"
-H "OSBN: OSBN-01-001-000001-001-4"
-H "Testing: true"
-F "cover_image=@C:/Users/Emma/Desktop/Emma After Harry cover.png"
-F "author_image=@C:/Users/Arne/Desktop/Emma Watson.jpg"
Example 4: cURL Command: (delete existing cover image and author image)
curl -X POST https://api.osbn.io/v1/postimages.php \
-H "Authorization: Wmp6ADsd8PtWfMODoaYMXNHIjhHA5Ws" \
-H "OSBN: OSBN-01-001-000001-001-4" \
-F "cover_url=." \
-F "author_image=@."
Responses:
- If the POSTed data is accepted and the provided token is valid, you will receive a JSON response containing the book's OSBN.
- If the request is unauthorized or if the data is not accepted, appropriate error responses will be provided.
Response Example (Success):
{
"status":"success",
"message":"POSTimages Success!",
"osbn":"OSBN-01-001-000001-001-4"
}
Response Example (Invalid OSBN (or an OSBN that you don't own)):
{
"status":"error",
"message":"Invalid OSBN: OSBN-01-001-000001-001-4"
}
Response Example (Missing required field):
{
"status":"error",
"message":"At least one field is required: cover_image, author_image, cover_url, or author_url."
}