Jump to content

Question

Posted

Всех приветствую. Необходимо отправлять API запросы роутеру через curl. В терминале ввожу такой код и получаю ошибку в логе роутера Core::Scgi::Session: unsupported method "POST" for "/rci".
Как правильно сделать запрос?

curl -u admin:password -X POST http://192.168.0.1/rci \
-H "Content-Type: application/json" \
-d '{
  "ip": {
    "hotspot": {
      "host": {
        "mac": "мак адрес",
        "permit": true,
        "policy": "Policy0"
      }
    }
  },
  "system": {
    "configuration": {
      "save": {}
    }
  }
}'



В Web CLI запрос выглядит так и успешно обрабатывается:

{
  "ip": {
    "hotspot": {
      "host": {
        "mac": "мак адрес",
        "permit": true,
        "policy": "Policy0"
      }
    }
  },
  "system": {
    "configuration": {
      "save": {}
    }
  }
}

4 answers to this question

Recommended Posts

  • 0
Posted
19 минут назад, Kifard сказал:

Всех приветствую. Необходимо отправлять API запросы роутеру через curl. В терминале ввожу такой код и получаю ошибку в логе роутера Core::Scgi::Session: unsupported method "POST" for "/rci".
Как правильно сделать запрос?

 

Добавьте слэш после /rci -> /rci/

  • 0
Posted
6 минут назад, eralde сказал:

Добавьте слэш после /rci -> /rci/

Получаю

<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>Web server</center>
</body>
</html>

 

  • 0
Posted
12 минуты назад, Kifard сказал:

Получаю

<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>Web server</center>
</body>
</html>

 

Сначала авторизуетесь, получаете от сервера сессионный Cookie, затем отправляете POST-запрос.
По авторизации:
 

 

  • 0
Posted

Если хотите обычную digest-авторизацию, то можно настроить специальным образом ip http proxy.


Пример описан тут:

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

This site uses cookies. By clicking "I accept" or continuing to browse the site, you authorize their use in accordance with the Privacy Policy.