Hello Developers!
This tutorial is in order to manage your medias using the version 1.0 of Sandbox BotDoc API. In order to use this version, you have to put “v1” on the API’s endpoint.
To a better understanding about the versioning, please go to api.botdoc.io/documentation/#versioning
and to a better understanding about the Sandbox, please go to api.botdoc.io/documentation/#sandbox-platform
1. Getting your medias:
In order to get a list of your medias you have to make a request to:
https://sandboxapi.botdoc.io/v1/auth/media/ as GET and you can use 2 parameters: (just like getting your requests)
page
to return the result set based on this page number (starting from 1, not 0), and page_size
that is the number of results per page.
If you don’t pass any parameter, page
‘s default is 1 and page_size
‘s default is 10.
If you send a request like this: https://api.botdoc.io/v1/media/
The response will look like the example below:
e.g.
{ "links": { "previous": null, "next": "https://api.botdoc.io/v1/request/?media=2" }, "total_pages": 2, "count": 12, "results": [{ "id": 52145, "request": 9685, ... }, ...{ "id": 52146, "request": 9685, ... } ] }
The response is similar as getting your requests, of course, the results will be medias instead of requests.
2. Getting a specific media:
In order to get a specific media you have to make a request to:
https://sandboxapi.botdoc.io/v1/auth/media/{media-id} as GET
and the response will look like the example below:
e.g.
{ "id": 6543321, "request": 944256354, "name": "image.png", "content_type": "image/png", "bytes": 958774, "extension": "png", "created": "2018-01-30T18:59:14Z", "updated": "2018-01-30T18:59:14Z" }
This endpoint does NOT retrieve the file’s content. In order to do so, you have to use the endpoint below, Download media.
3. Download a media:
In order to download a specific media you have to make a request to:
https://sandboxapi.botdoc.io/v1/auth/media/{media-id}/download as GET
The body response is the file’s content.
4. Delete a media:
BotDoc automatically deletes the medias, but you can delete earlier if you don’t want to wait.
In order to delete a specific media you have to make a request to:
https://sandboxapi.botdoc.io/v1/auth/media/{media-id}/as DELETE
The response will be the HTTP Code 204 when the deleting is successful.
5. Create a media:
You can create a media to a existing request in order to send files. You can take a look at our tutorial Sending your first requests on the 7th step.