【问题标题】:API response is html and not JsonAPI 响应是 html 而不是 Json
【发布时间】:2018-12-19 03:19:02
【问题描述】:

我正在尝试连接到 FortiSandbox api,guide here

指南摘录:

我的用户名:admin

我的密码:Aa12345!

cURL:

    curl -X POST \
  https://10.1.1.170/sys/login/user/ \
  -H 'accept: application/json' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'postman-token: bd3ae694-f400-c723-8955-bfc4e96c8147' \
  -d '{
  "method": "exec",
  "params": [{
    "url": "/sys/login/user/",
    "data": [{
      "user": "admin",
      "passwd": "Aa12345!"
    }]
  }],
  "id": 1,
  "ver": "2.0"
}'

响应是 HTML 而不是 Json,here full HTML content response

请给绝望的人一些建议 部分 HTML 响应:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>FortiSandbox - Please login</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        .
        .
        .

【问题讨论】:

  • 代码共享已关闭
  • 请在您的问题中直接包含与您的问题相关的所有信息,而不是在可能随时关闭的外部网站上。
  • 考虑到此 HTML 文档的 title 元素显示“FortiSandbox - 请登录”,您的请求身份验证可能有问题。
  • 看来登录请求是使用EXEC作为方式(也有比较标准的GET和POST,有没有试过用Chrome和Devtools查看浏览器和登录方式之间的流量?
  • 那么可能您的请求格式不正确,或者您没有将其发送到正确的端点。

标签: json api curl postman


【解决方案1】:
curl -X POST http://10.1.1.170/jsonrpc -H 'accept: application/json' -H 'cache-control: no-cache' -H 'content-type: application/json' -H 'postman-token: bd3ae694-f400-c723-8955-bfc4e96c8147' -d '{"method": "exec","params": [{"url": "/sys/login/user","data": [{"user": "admin","passwd": "Aa12345!"}]}],"id": 1,"ver": "2.0"}'

【讨论】:

  • 亲爱的 Jp FernandeZ,如果您在裸代码之外发布一些额外的 cmets 来澄清您的答案,那就太好了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-25
  • 2021-05-03
  • 2021-12-01
  • 2016-05-30
  • 2016-09-09
  • 1970-01-01
相关资源
最近更新 更多