Any Media [PATCH] Method (PATCH)

Any Media [PATCH] method is used to add tags to an existing file in the folder or update them.

Additional Request Parameters.

  • media_id: unique identifier of the target file (in the request headline);
  • tags: tags to be added in "tags": [“value1,value2…valueN"] format (in the request body). To clear all tags, leave the value part empty ("tags": []). Tag requirements for different data types.

Request Examples.

Example of running the Any Media [PATCH] method in Postman:

Examples of PATCH request syntax using Any Media [PATCH] method with following parameters:

  • File ID “2d678796-933d-450e-a1d4-6dcf47011095”;
  • Add tags "photo_id","photo_id_front” to the file.

HTTP

Bash

Python

php

Java


PATCH /api/media/2d678796-933d-450e-accf-6dcf47011095 HTTP/1.1
Host: youradress.ru
X-Forensic-Access-Token: 0ccbdb4627c9d07c6c5b8f6e6cca44b5f8cb0c54ad7659098fa336240d494b0f9035e14bc42fc461224a9719f105e41026fed0f6f14188d9107b8c3d697a0cb1
Content-Type: application/json
User-Agent: PostmanRuntime/7.15.2
Accept: */*
Cache-Control: no-cache
Postman-Token: 2b147058-dad7-408b-8db0-68e2a92cfd45,29dad827-93ac-400c-b269-f9640a932486
Host: youradress.ru
Accept-Encoding: gzip, deflate
Content-Length: 42
Connection: keep-alive
cache-control: no-cache

{
  "tags": ["photo_id","photo_id_front"]
}


curl -X PATCH \
  https://youradress.ru/api/media/2d678796-933d-450e-accf-6dcf47011095 \
  -H 'Accept: */*' \
  -H 'Accept-Encoding: gzip, deflate' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Length: 42' \
  -H 'Content-Type: application/json' \
  -H 'Host: youradress.ru' \
  -H 'Postman-Token: 2b147058-dad7-408b-8db0-68e2a92cfd45,67f16415-0917-4963-ba32-11016e83217c' \
  -H 'User-Agent: PostmanRuntime/7.15.2' \
  -H 'X-Forensic-Access-Token: 0ccbdb4627c9d07c6c5b8f6e6cca44b5f8cb0c54ad7659098fa336240d494b0f9035e14bc42fc461224a9719f105e41026fed0f6f14188d9107b8c3d697a0cb1' \
  -H 'cache-control: no-cache' \
  -d '{
  "tags": ["photo_id","photo_id_front"]
}'


import requests

url = "https://youradress.ru/api/media/2d678796-933d-450e-accf-6dcf47011095"

payload = "{\n\t\"tags\": [\"photo_id\",\"photo_id_front\"]\n}"
headers = {
    'X-Forensic-Access-Token': "0ccbdb4627c9d07c6c5b8f6e6cca44b5f8cb0c54ad7659098fa336240d494b0f9035e14bc42fc461224a9719f105e41026fed0f6f14188d9107b8c3d697a0cb1",
    'Content-Type': "application/json",
    'User-Agent': "PostmanRuntime/7.15.2",
    'Accept': "*/*",
    'Cache-Control': "no-cache",
    'Postman-Token': "2b147058-dad7-408b-8db0-68e2a92cfd45,2de0dbf6-d589-4e7e-9525-547bc8cadcb5",
    'Host': "youradress.ru",
    'Accept-Encoding': "gzip, deflate",
    'Content-Length': "42",
    'Connection': "keep-alive",
    'cache-control': "no-cache"
    }

response = requests.request("PATCH", url, data=payload, headers=headers)

print(response.text)


setUrl('https://youradress.ru/api/media/2d678796-933d-450e-accf-6dcf47011095');
$request->setMethod(HttpRequest::HTTP_METH_PATCH);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'Connection' => 'keep-alive',
  'Content-Length' => '42',
  'Accept-Encoding' => 'gzip, deflate',
  'Host' => 'youradress.ru',
  'Postman-Token' => '2b147058-dad7-408b-8db0-68e2a92cfd45,3ae874ce-fd14-4270-bab4-0a7a92abce2e',
  'Cache-Control' => 'no-cache',
  'Accept' => '*/*',
  'User-Agent' => 'PostmanRuntime/7.15.2',
  'Content-Type' => 'application/json',
  'X-Forensic-Access-Token' => '0ccbdb4627c9d07c6c5b8f6e6cca44b5f8cb0c54ad7659098fa336240d494b0f9035e14bc42fc461224a9719f105e41026fed0f6f14188d9107b8c3d697a0cb1'
));

$request->setBody('{
  "tags": ["photo_id","photo_id_front"]
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}


OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"tags\": [\"photo_id\",\"photo_id_front\"]\n}");
Request request = new Request.Builder()
  .url("https://youradress.ru/api/media/2d678796-933d-450e-accf-6dcf47011095")
  .patch(body)
  .addHeader("X-Forensic-Access-Token", "0ccbdb4627c9d07c6c5b8f6e6cca44b5f8cb0c54ad7659098fa336240d494b0f9035e14bc42fc461224a9719f105e41026fed0f6f14188d9107b8c3d697a0cb1")
  .addHeader("Content-Type", "application/json")
  .addHeader("User-Agent", "PostmanRuntime/7.15.2")
  .addHeader("Accept", "*/*")
  .addHeader("Cache-Control", "no-cache")
  .addHeader("Postman-Token", "2b147058-dad7-408b-8db0-68e2a92cfd45,d1b49940-d18b-4329-bc54-b61f3f2c6dd4")
  .addHeader("Host", "youradress.ru")
  .addHeader("Accept-Encoding", "gzip, deflate")
  .addHeader("Content-Length", "42")
  .addHeader("Connection", "keep-alive")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

Example of JSON Response.

Example of the system's JSON response to calling Any Media [PATCH] method with similar settings:

JSON


{
    "time_created": 1579857057,
    "time_updated": 1579858652,
    "meta_data": {},
    "media_id": "2d678796-933d-450e-accf-6dcf47011095",
    "media_type": "IMAGE_FOLDER",
    "info": {
        "thumb": {
            "md5": "e797fba781c5d493648cf892993c8982",
            "size": 14077,
            "width": 300,
            "height": 189,
            "mime-type": "image/jpeg"
        },
        "original": {
            "md5": "7db11e1e3d2676558d1e2ea4a732e4b0",
            "size": 40402,
            "width": 766,
            "height": 483,
            "mime-type": "image/jpeg"
        }
    },
    "tags": [
        "photo_id",
        "photo_id_front"
    ],
    "original_name": "90eace77-ca39-45fa-853e-b9495d389640.jpeg",
    "image_id": "2d678796-933d-450e-accf-6dcf47011095",
    "original_url": "http://youradress.ru/static/f5fea1c1-5797-487a-b0f5-673eea2f8a79/2d678796-933d-450e-accf-6dcf47011095.jpeg",
    "thumb_url": "http://youradress.ru/static/f5fea1c1-5797-487a-b0f5-673eea2f8a79/2d678796-933d-450e-accf-6dcf47011095_thumb.jpeg"
}

Details of JSON Response

The response contains information on file updates.