{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ru/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Вызов шаблона через HTTP","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"вызов-шаблона-через-http","__idx":0},"children":["Вызов шаблона через HTTP"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"1-получение-авторизации-токен-oauth2","__idx":1},"children":["1. Получение авторизации (токен OAuth2)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Перед вызовом любых функциональных API необходимо обменять свои учетные данные на ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["токен доступа JWT"]},"."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Конечная точка:"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST https://api.morelogin.com/oauth2/token"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Официальная документация:"]}," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://guide.morelogin.com/api-reference/open-api/open-api/authorization/paths/~1oauth2~1token/post"},"children":["Путь авторизации"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"запрос-curl","__idx":2},"children":["Запрос (cURL)"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -i -X POST \\\n  https://api.morelogin.com/oauth2/token \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"client_id\": 1672940217990530,\n    \"client_secret\": \"your_client_secret\",\n    \"grant_type\": \"client_credentials\"\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"пример-ответа","__idx":3},"children":["Пример ответа"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"code\": 0,\n    \"data\": {\n        \"access_token\": \"eyJhbGciOiJIUzI1NiIsIn...\",\n        \"token_type\": \"Bearer\",\n        \"expires_in\": 3600\n    }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"2-выполнение-шаблона-cloud-phone","__idx":4},"children":["2. Выполнение шаблона Cloud Phone"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Используйте access_token, полученный на шаге 1, для запуска определенного шаблона RPA."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Конечная точка:"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST https://api.morelogin.com/cloudphone/rpa/onceTask/save"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Официальная документация:"]}," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://guide.morelogin.com/api-reference/open-api/open-api/cloud-phoneschedules-management/paths/~1cloudphone~1rpa~1oncetask~1save/post"},"children":["Путь выполнения расписания"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"запрос-curl-1","__idx":5},"children":["Запрос (cURL)"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -i -X POST \\\n  https://api.morelogin.com/cloudphone/rpa/onceTask/save \\\n  -H 'Authorization: Bearer <YOUR_JWT_HERE>' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"cloudPhoneId\": 16783319661123,\n    \"scheduleName\": \"test_automation\",\n    \"templateId\": 1678347487160256,\n    \"templateParameter\": \"{\\\"Video Caption\\\": \\\"Hello World\\\", \\\"AI Label\\\": true}\",\n    \"description\": \"schedule description\"\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"3-разбор-параметров","__idx":6},"children":["3. Разбор параметров"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"как-получить-идентификаторы","__idx":7},"children":["Как получить идентификаторы?"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Авторизация:"]}," Получается через конечную точку ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/oauth2/token"]},"."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["cloudPhoneId:"]}," Находится на панели управления MoreLogin Cloud Phone (числовой идентификатор)."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["templateId:"]}," Находится на рынке шаблонов автоматизации или в личном списке шаблонов."]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"понимание-параметра-templateparameter","__idx":8},"children":["Понимание параметра templateParameter"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Это строковый JSON-объект. Необходимо определить ключи в соответствии с требованиями шаблона, а затем экранировать их в виде строки."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Пример определения шаблона:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"Video Caption\": \"string\",\n    \"AI Label\": \"boolean\",\n    \"Product Id\": \"number\",\n    \"Get Leads\": \"boolean\",\n    \"Comment\": \"string\"\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Как это сопоставить в вашем запросе:"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Чтобы передать значения для указанного выше определения, значение вашего templateParameter должно выглядеть следующим образом:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"templateParameter\": \"{\\\"Video Caption\\\": \\\"My Title\\\", \\\"AI Label\\\": true, \\\"Product Id\\\": 12345}\"\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"4-обработка-ошибок","__idx":9},"children":["4. Обработка ошибок"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["| Статус | Возможная причина |"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["| ---------------- | ------------------------------------------------------------ |"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["| 401 Unauthorized | Срок действия токена истек или недействительны учетные данные клиента. |"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["| 400 Bad Request | Недействительный cloudPhoneId или некорректный JSON в templateParameter. |"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["| 404 Not Found | Идентификатор шаблона не существует. |"]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"быстрый-старт-python","__idx":10},"children":["Быстрый старт Python"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\nimport json\n\ndef run_morelogin_task():\n    # 1. Auth\n    auth_res = requests.post(\n        \"https://api.morelogin.com/oauth2/token\",\n        json={\n            \"client_id\": 1672940217990530,\n            \"client_secret\": \"your_secret\",\n            \"grant_type\": \"client_credentials\"\n        }\n    )\n    token = auth_res.json()['data']['access_token']\n\n    # 2. Execute\n    task_payload = {\n        \"cloudPhoneId\": 16783319661123,\n        \"templateId\": 1678347487160256,\n        \"templateParameter\": json.dumps({\n            \"Video Caption\": \"My Post\",\n            \"AI Label\": True\n        })\n    }\n    \n    headers = {\"Authorization\": f\"Bearer {token}\"}\n    response = requests.post(\n        \"https://api.morelogin.com/cloudphone/rpa/onceTask/save\",\n        json=task_payload,\n        headers=headers\n    )\n    return response.json()\n\nprint(run_morelogin_task())\n","lang":"python"},"children":[]}]},"headings":[{"value":"Вызов шаблона через HTTP","id":"вызов-шаблона-через-http","depth":1},{"value":"1. Получение авторизации (токен OAuth2)","id":"1-получение-авторизации-токен-oauth2","depth":2},{"value":"Запрос (cURL)","id":"запрос-curl","depth":3},{"value":"Пример ответа","id":"пример-ответа","depth":3},{"value":"2. Выполнение шаблона Cloud Phone","id":"2-выполнение-шаблона-cloud-phone","depth":2},{"value":"Запрос (cURL)","id":"запрос-curl-1","depth":3},{"value":"3. Разбор параметров","id":"3-разбор-параметров","depth":2},{"value":"Как получить идентификаторы?","id":"как-получить-идентификаторы","depth":3},{"value":"Понимание параметра templateParameter","id":"понимание-параметра-templateparameter","depth":3},{"value":"4. Обработка ошибок","id":"4-обработка-ошибок","depth":2},{"value":"Быстрый старт Python","id":"быстрый-старт-python","depth":2}],"frontmatter":{"seo":{"title":"Вызов шаблона через HTTP"}},"lastModified":"2026-06-10T11:47:34.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ru/rparobotic-process-automation/04-integration/call-template-via-http","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}