cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1043
Views
10
Helpful
4
Replies

Patch a leaflist RESTCONF

Gastonper
Level 1
Level 1

Hi, I have some server with a leaf-list in it.

 

I want to edit the elements in this leaf-list via RESTCONF.

 

If I do something like this:

 

curl -i -X PATCH http://X.X.X.X:YYY/restconf/data/services/myservice -H "Content-Type: application/yang-data+json" --data '{"myservice:serviceA": [ {"label": "new-label"}]}' 

The leaf-list "label" adds the string "new-label". But sometime I want to replace the entire content of "label" with my new label, and not just add the new string to the list.

 

Is it possible to do this? What path or method do I need to pass?

 

Thanks

 

1 Accepted Solution

Accepted Solutions

I meat a PUT directly into the leaf-list and not on the service list above.

 

Your URL should look like:

http:/X.X.X.X:YYY/restconf/data/services/myservice=serviceA/label

 

And the encoding something like:

{"lable": [123, 0]}

 

View solution in original post

4 Replies 4

rogaglia
Cisco Employee
Cisco Employee
Hi,
Shouldn’t you be using PUT instead of PATCH for this usecase?
Roque

If I use PUT, NSO try tu make a new instance of myservice and I get an error. Maybe the restconf path is wrong

My service:

list myservice{
	key "code";
	
	leaf code {
		type string;
	}
	
	...
	
	leaf-list label {
		type string;
	}
}

RESTCONF:

curl -i -X PUT http:/X.X.X.X:YYY/restconf/data/services/myservice -H "Content-Type: application/yang-data+json" --data '{"myservice:myservice": [ {"code": "serviceA", "label": "new-label"}]}' 

 

Is any good way to know the correct url for restconf?. Maybe in cli with commit dry-run | display keypath or something like that.

I meat a PUT directly into the leaf-list and not on the service list above.

 

Your URL should look like:

http:/X.X.X.X:YYY/restconf/data/services/myservice=serviceA/label

 

And the encoding something like:

{"lable": [123, 0]}

 

Thats works,

 

Thank you!