0

I'm trying to call the setMyCommands API via curl according to this answer. I first tried

curl -L -X "POST" \
    "https://api.telegram.org/bot$TELEGRAM_TOKEN"'/setMyCommands?commands=[{ "command": "command", "description": "description" }]'

curl printed the following error.

curl: (3) bad range specification in URL position

Then I tried to use curl with --globoff flag.

curl --globoff -L -X "POST" \
    "https://api.telegram.org/bot$TELEGRAM_TOKEN"'/setMyCommands?commands=[{ "command": "command", "description": "description" }]'

Now it printed the following error.

curl: (3) URL using bad/illegal format or missing URL

What is the correct way to call it?

Jason Lee
  • 502
  • 6
  • 15

1 Answers1

1

I guess you are using Windows. Try this:

curl -X POST -H "Content-Type: application/json" -d "{\"commands\":[{\"command\":\"test\",\"description\":\"description with spaces\"}]}" https://api.telegram.org/bot$TELEGRAM_TOKEN/setMyCommands

The trick is to escape double quotes in the JSON with a backslash. It would work even for the command you are using, sending the commands in the query, but using -d (shortcut for --data) option makes it easier to include spaces in the description of the commands.

druskacik
  • 2,176
  • 2
  • 13
  • 26