02-05-2019 04:27 AM
Hi all,
I'm trying to run commands on devices (configurations) using the RESTCONF API, but I'm struggling to find how to execute multi line commands and then do a Dry-Run. I was able to run single line commands, but not commit them.
Any hint here?
Best regards,
Alex.
02-05-2019 04:58 AM
What do you mean by 'multi-line commands'?
02-05-2019 09:39 AM
Hi, well I mean something like the load merge on the cli, where we can put a bunch of lines to configure multiple paths of the configuration in one shot.
02-06-2019 01:41 AM
The PATCH method in RESTCONF does something very similar to what load merge does in the CLI. The body of the message can contain several lines of XML/JSON. This might be what you want to use.
02-06-2019 11:39 AM
02-12-2019 01:11 AM
Example of RESTCONF PATCH with multiple deletes in a single command.
I have not tried to do "dry-run" with PATCH media type, but I believe you need to add "?dryrun=native" to the URI:
'http://127.0.0.1:{{port_upper}}/restconf/data?dryrun=native' (Please let us know if that works)
Roque
curl -X PATCH \
'http://127.0.0.1:{{port_upper}}/restconf/data' \
-H 'Accept: application/yang-data+json' \
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
-H 'Content-Type: application/yang-patch+json' \
-H 'Postman-Token: 2a398902-c503-45ab-8dfb-98074171c71d' \
-H 'cache-control: no-cache' \
-H 'password: admin' \
-H 'username: admin' \
-d ' {
"ietf-yang-patch:yang-patch" : {
"patch-id" : "delete-before-start-1",
"edit" : [
{
"edit-id" : "edit1",
"operation" : "delete",
"target" : "/mef-legato-services:mef-services"
},
{
"edit-id" : "edit2",
"operation" : "delete",
"target" : "/mef-legato-interfaces:mef-interfaces"
},
{
"edit-id" : "edit3",
"operation" : "delete",
"target" : "/ietf-network:networks"
}
]
}
}'
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide