首页 > 解决方案 > 为什么 curl json 身份验证不起作用?

问题描述

当我使用此代码进行身份验证时:

curl -d -H "Accept: application/json" \
{"id":"1","method":"authenticate","params":{"user":"USER","password":"PASSWORD","client":"CLIENT", "?school":"htl-donaustadt"},"jsonrpc":"2.0"} \
https://melete.webuntis.com/WebUntis/jsonrpc.do?school=htl-donaustadt \
--insecure

我收到此错误消息:

curl:(3)[globbing]第27列中不匹配的右大括号/方括号

{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"解析错误:由于输入结束,没有要映射的内容\n at [来源:org.apache.catalina.connector.CoyoteInputStream@102d63fc;行:1,列:0]"}}

标签: jsoncurl

解决方案


根据一些非公开文档,您需要做的是对https://server.webuntis.com/WebUntis/jsonrpc.do?school=School+nameurl 的请求,并以此作为正文。很抱歉,我无法与您分享文档。我想你可以在 untis 帮助台上申请。

{
    "params": {
        "user": "xxx_user",
        "password": "xxx_password",
        "client": "Roostersync proxy"
    },
    "id": "random_id_here",
    "method": "authenticate",
    "jsonrpc": "2.0"
}

或者 curl 命令

curl -X POST \
  'https://melete.webuntis.com/WebUntis/jsonrpc.do?school=htl-donaustadt' \
  -H 'Content-Type: application/json' \
  -d '{
    "params": {
        "user": "user",
        "password": "password",
        "client": "Your client name"
    },
    "id": "7e6431bc-36c2-4118-991d-6459ab5b01e2",
    "method": "authenticate",
    "jsonrpc": "2.0"
}'

推荐阅读