[NETCONF-2] Cannot perform any operations on leaves Created: 14/May/14  Updated: 15/Mar/19  Resolved: 10/Oct/17

Status: Resolved
Project: netconf
Component/s: restconf-nb
Affects Version/s: None
Fix Version/s: None

Type: Improvement
Reporter: Rob Adams Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


Issue Links:
Blocks
is blocked by NETCONF-18 Enhance RESTconf to implement latest ... Resolved

 Description   

This should work according to the swagger API docs, but does not:

$ curl http://localhost:8080/restconf/config/toaster:toaster/darknessFactor
URI has bad format. Node "darknessFactor" must be Container or List yang type.

So should this (PUT and POST give the same error):
$ curl -X POST -H 'Content-Type: application/yang.data+json' -d '2000' http://localhost:8080/restconf/config/toaster:toaster/darknessFactor
<html><head><title>Apache Tomcat/7.0.32 - Error report</title><style><!--H1

{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}

H2

{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}

H3

{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}

BODY

{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}

B

{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}

P

{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}

A

{color : black;}

A.name

{color : black;}

HR

{color : #525D76;}

--></style> </head><body><h1>HTTP Status 500 - java.lang.String cannot be cast to org.opendaylight.controller.sal.restconf.impl.StructuredData</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>java.lang.String cannot be cast to org.opendaylight.controller.sal.restconf.impl.StructuredData</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>java.lang.ClassCastException: java.lang.String cannot be cast to org.opendaylight.controller.sal.restconf.impl.StructuredData
org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider.getSize(StructuredDataToXmlProvider.java:39)
com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:289)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1479)



 Comments   
Comment by Tom Pantelis [ 21/May/14 ]

The cast exception is fixed with CONTROLLER-472. The POST command above with -d '2000' now returns error:

"Root element of Json has to be Object"

which makes sense because it isn't valid json.

Issuing this:

curl -X POST -H 'Content-Type: application/json' -d '

{darknessFactor: "2000"}

' http://localhost:8080/restconf/config/toaster:toaster/darknessFactor

yields this error:

"First element in Json Object has to be "Object" or "Array with one Object element". Other scenarios are not supported yet."

So the controller's restconf doesn't (yet) support GET/PUT/POST to leaf nodes. The RESTCONF spec doesn't appear to preclude it.

Comment by Tom Pantelis [ 30/May/14 ]

The RESTCONF spec states "Only YANG container and list data node types are considered to represent data resources. Other YANG data nodes are considered to be fields within their parent resource."

The target type for a PUT (also for POST) is a data resource. Therefore, by the definition of data resource, PUT is not allowed for a leaf field of a data resource.

It seems the PATCH method is intended to perform CUD on leaf fields, which is not currently implemented in ODL.

Comment by Rob Adams [ 30/May/14 ]

At a minimum, we need to make these not appear in the API docs.

Comment by Jozef Gloncak [ 26/Sep/14 ]

Currently only lists (with key values) or containers are presents in swagger URI links.

If no other comments with additional requests will appear in few days regarding this bug I will close it.

Comment by Tony Tkacik [ 12/May/15 ]

This would require upgrade of restconf to latest drafts.

Comment by Robert Varga [ 13/Nov/15 ]

Move to NETCONF project

Comment by Robert Varga [ 10/Oct/17 ]

Fixed in RFC8040 restconf

Generated at Wed Feb 07 20:13:55 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.