Configuring OSPF via the API

Hello,
I am trying to add a network to my OSPF configuration using the API. I’m doing this with curl in a bash script, and for some reason I’m being told that the configuration path is invalid.

The script collects input (x.x.x.x/yy), and puts it in a variable, then attempts to connect and configure, but it fails.

Here’s the script:
echo “Enter the network to be advertised:”
read network
curl --insecure --location --request POST ‘https://10.0.0.2/configure’ --form data=‘{“op”: “set”, “path”: [“protocols”,“ospf”,“area 0”,“network ‘$network’”]}’ --form key=‘apikey’

The response is a failure, and the included text says:
Configuration path: [protocols ospf area 0 network x.x.x.x/yy] is not valid\n\nSet failed\n", “data”: null}

Can someone tell me the right way to format this?
Thank you

There is an example of worling configuration

root@r14:/home/vyos# cat c_ospf.sh 
#!/usr/bin/env bash

network="10.0.0.0/24"

curl --insecure --location --request POST 'https://localhost/configure' --form data='{"op": "set", "path": ["protocols","ospf","area","0","network", "'$network'"]}' --form key='foo'
root@r14:/home/vyos# 
root@r14:/home/vyos# ./c_ospf.sh 
{"success": true, "data": null, "error": null}
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.