Home
Help
Search
Login
Register
OPNsense Forum
»
Archive
»
19.1 Legacy Series
»
Trouble with using API
« previous
next »
Print
Pages: [
1
]
Author
Topic: Trouble with using API (Read 3178 times)
gertfriend
Newbie
Posts: 19
Karma: 2
Trouble with using API
«
on:
March 15, 2019, 02:36:57 pm »
Hello,
i have trouble with the API.
I use curl. For now the following commands work:
curl -k -u "key":"secret"
https://192.168.1.1/api/core/firmware/status
and
curl -XPOST -d '{}' -H "Content-Type: application/json" -k -u "key":"secret"
https://192.168.1.1/api/core/firmware/poweroff
But none of the following commands work:
curl -XPOST -d '{"upgrade":"all"}' -H "Content-Type: application/json" -k -u "key":"secret"
https://192.168.1.1/api/core/firmware/upgrade
nor
curl -XPOST -d '{"address":"1.0.1.10"}' -H "Content-Type: application/json" -k -u "key":"secret"
https://192.168.1.1/api/firewall/alias_util/add/BANNED
The result is always {"status":"failure"}.
And what should be posted to do a release update: 18.7 to 19.1
Thanks for any help
Logged
gertfriend
Newbie
Posts: 19
Karma: 2
Re: Trouble with using API
«
Reply #1 on:
March 21, 2019, 10:00:33 am »
Sorry Franco, i didn't want nerve you and your team seen witch great work you do, i only thought that more people are using API and could help resolve the problem.
Now i resolved it. The problem was, that i was using curl from windows and windows has since ever trouble with quotas respectively double quotas so the solution for windowsuser is to enter change the -d in "{\"upgrade\":\"all\"}" so the single quotas should be replaced with double quotas and the double quotas will be escaped.
curl -XPOST -d "{\"upgrade\":\"all\"}" -H "Content-Type: application/json" -k -u "key":"secret"
https://192.168.1.1/api/core/firmware/upgrade
«
Last Edit: April 02, 2019, 04:21:11 pm by gertfriend
»
Logged
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
Archive
»
19.1 Legacy Series
»
Trouble with using API