cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1226
Views
20
Helpful
2
Replies

Difference between POST and PATCH URLS in RESTCONF

neetimit
Cisco Employee
Cisco Employee

I have a question on RESTCONF, when I create a POST request, in the URL  if I give http://localhost:8080/restconf/data it gives "object already exists: tail:services" error which makes sense as it is a POST request. so the correct url is http://localhost:8080/restconf/data/tailf:services with the payload something like:

 

{

"router-bgp:router-bgp": [{
"device": "CE11",
"service-name":"bgp3",
"ios": {
"bgp": [{
"id": "21"
}]
}
}]
}

 

But in case of PATCH, in the URL if I give http://localhost:8080/restconf/data/tailf:services, it doesn't work and gives "missing element" error. so instead of giving "tails:services" in url, we give it in the payload and then it works for PATCH request.

 

can anyone please help to understand the difference in URLs for POST and PATCH in RESTCONF?

 

Thanks,

Neetika

1 Accepted Solution

Accepted Solutions

yfherzog
Cisco Employee
Cisco Employee

When you do a POST, you provide the URI for where an instance is going to be created.

When you do a PATCH, you provide the URI to the node you want to modify.

 

So, there are actually more ways to go about the call you did than the ones you mentioned.

If you want to do a PATCH on the list, then you need to include the identifier(s) to the list element inside your URI, and then you'd be able to PATCH the instance (that's the error message you've been getting).

You may also create the instance with a PATCH in the first place given that you provide the right URI and payload (same one as you provided for the PATCH call that works for you).

 

Ultimately, it's down to the semantics of whether you modify the content in the URI you specify, or create an instance on that URI.

Whatever URI you provide needs to correspond to the payload that goes along with it - namely, the root of the payload will be different depending on the depth of the URI you provide.

 

Have a look at the RESTCONF RFC for some more details:

https://tools.ietf.org/html/rfc8040

 

Hope it makes some sense!

View solution in original post

2 Replies 2

yfherzog
Cisco Employee
Cisco Employee

When you do a POST, you provide the URI for where an instance is going to be created.

When you do a PATCH, you provide the URI to the node you want to modify.

 

So, there are actually more ways to go about the call you did than the ones you mentioned.

If you want to do a PATCH on the list, then you need to include the identifier(s) to the list element inside your URI, and then you'd be able to PATCH the instance (that's the error message you've been getting).

You may also create the instance with a PATCH in the first place given that you provide the right URI and payload (same one as you provided for the PATCH call that works for you).

 

Ultimately, it's down to the semantics of whether you modify the content in the URI you specify, or create an instance on that URI.

Whatever URI you provide needs to correspond to the payload that goes along with it - namely, the root of the payload will be different depending on the depth of the URI you provide.

 

Have a look at the RESTCONF RFC for some more details:

https://tools.ietf.org/html/rfc8040

 

Hope it makes some sense!

Thank you very much, that was helpful!