1
votes

When I use this code to get authenticated :

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

I get this error message :

curl: (3) [globbing] unmatched close brace/bracket in column 27

{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error: No content to map due to end-of-input\n at [Source: org.apache.catalina.connector.CoyoteInputStream@102d63fc; line: 1, column: 0]"}}

2

2 Answers

0
votes

To POST data in JSON format, add -H "Content-Type: application/json". Without this, curl will use application/x-www-form-urlencoded.

The JSON post data also needs to be quoted, and set immediately after the -d flag.

Based on your original command, try:

curl -H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"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
0
votes

According to some non-public documentation the request you'll need to do is to the https://server.webuntis.com/WebUntis/jsonrpc.do?school=School+name url, with this as body. I'm sorry I cannot share the documentation with you. I think you can request it at the untis helpdesk.

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

Or curl command

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"
}'