OPNsense Forum

English Forums => General Discussion => Topic started by: barryfo on March 08, 2019, 06:08:23 pm

Title: Assistance with Adding a trafficshaper through Rest API
Post by: barryfo on March 08, 2019, 06:08:23 pm
Hi All,

I have been trying to find the correct format for the trafficshaper APIs.  The only result I ever get is "failed" which is basically any validation failure.  Trying to parse through the code and haven't had any luck getting the right combination.  As anyone added pipes, queues, and rules via Rest?

An example of one of my attempts:

curl -v -XPOST -d '{"number":"100","enabled":"1","bandwidth":"300","bandwidthMetric":"Kbit","mask":"none","codel_enable":"0","codel_ecn_enable":"0","pie_enable":"0","description":"TestPipe"}' -H "Content-Type: application/json" -k -u "<Key>":"<secret>" https://192.168.1.1/api/trafficshaper/settings/addpipe


{"result":"failed"}



Title: Re: Assistance with Adding a trafficshaper through Rest API
Post by: sdelaney01 on February 01, 2023, 04:20:51 pm
I've been having the same issue, and took a while to go through the forum.

This topic has the solution:
https://forum.opnsense.org/index.php?topic=30356.msg146448#msg146448 (https://forum.opnsense.org/index.php?topic=30356.msg146448#msg146448)

But for sake of completeness, your JSON body should look this this:

'{"pipe":{"number":"100","enabled":"1","bandwidth":"300","bandwidthMetric":"Kbit","mask":"none","codel_enable":"0","codel_ecn_enable":"0","pie_enable":"0","description":"TestPipe"}}'