Assistance with Adding a trafficshaper through Rest API

Started by barryfo, March 08, 2019, 06:08:23 PM

Previous topic - Next topic
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"}




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

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

Is there any example for JSON body for addRule?
Thank you