01-03-2020 01:40 PM
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:
{
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
Solved! Go to Solution.
01-04-2020 10:42 PM
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!
01-04-2020 10:42 PM
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!
01-06-2020 08:04 AM
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