Multimedia create
This is how you can create multimedia via API.
mutation {
multimediaCreate(
input: { name: "file_name.extension", folderPath: "folder_path" }
) {
__typename
}
}
Example in PHP8
$client = new \GuzzleHttp\Client(); // Guzzle version 6
$resp = $client->post(
$url,
[
'multipart' => [
[
'name' => 'upload',
'contents' => fopen(__DIR__ . '/test.png', 'r'),
],
[
'name' => 'query',
'contents' => '
mutation {
multimediaCreate(input: {name: "new.png", folderPath: null}) {__typename}
}
',
],
],
'headers' => [
'X-API-KEY' => $apiKey,
],
],
);
Example in Python3
from urllib import response
import requests
url = "https://marcin.ergonode.app/api/graphql/"
data = {
'upload': open('C:\\temp\\temp.png', 'rb'),
'query': (None, 'mutation{multimediaCreate(input:{name:"<choose_a_name>",folderPath: "<some_folder_path>"}){__typename}}')
}
headers = {
'X-API-KEY': '<some_api_key>',
}
response = requests.post(url, files=data, headers=headers)
print (response.text)
Last updated
Was this helpful?