Create a Media
This endpoint creates a Media
The allowed types for this endpoint are:
-
image for image upload. The endpoint retrieve the image associated with the given url and creates an image media type.
-
url for url fetch. The endpoint retrieve metadata associated with the given url and create a preview.
-
share for sharing a community contribute object (Post, Discussion or Status) or a community Event object. The community object can't contain a media of type share. The object should be pass as an id in the following parameter:
- shared_object: if the object is a contribute;
- event_object: if the object is an event.
-
embed for external objects. The endpoint create an association with an external object using Embed format.
If embed parameter are set and no Embed with embed_type
- embed_id
are in
the community database this endpoint create an Embed object with the metadata
passed.
This operation requires authentication
HTTP Request
POST /api/v2/media/
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
» type | body | string | true | The media type |
» url | body | string(uri) | if type is url | Required for type url |
» shared_object | body | integer | if type is share | Required for type share if you are sharing a content (post, discussion, status) |
» event_object | body | integer | if type is share | Required for type share if you are sharing an event |
» embed | body | Embed | if type is embed | The embed object |
Enumerated Values
Parameter | Value | Description |
---|---|---|
» type | image | Url media type |
» type | url | Url media type (used for any webpages, youtube etc.) |
» type | embed | External resource |
Example Body Parameters
- JSON
{
"type": "string",
"url": "string(uri)",
"embed": {Embed}
}
Example Request
- JavaScript
- Bash
const inputBody = '{
"type": "url",
"url": "https://example.com",
"embed": null
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization': 'Bearer {access_token}'
};
fetch('/api/v2/media/',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
# You can also use wget
curl -X POST /api/v2/media/ \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access_token}' \
--data-raw '{
"type": "string",
"url": "string(uri)",
}'
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
201 | Created | Response status code | Media |