cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
125
Views
0
Helpful
4
Replies
Highlighted
Beginner

Data Method Load example in JSON-RPC

Looking for an example of the Data Method: Load in JSON-RPC.

 

I've seen the documentation:

 

{"th": <integer>,
"data": <string>
"path": <string, default: "/">
"format": <"json" | "xml", default: "xml">
"mode": <"create" | "merge" | "replace", default: "merge">}

Though anything I seem to try - attempting json-data - doesn't seem to work. The RPC always returns a 

"reason": "invalid_trailing_data"
 
 

 

Everyone's tags (1)
4 REPLIES 4
Cisco Employee

Re: Data Method Load example in JSON-RPC

From the NSO Web UI Book, the load method's parameters are as stated

{"th": <integer>,
 "data": <string>
 "path": <string, default: "/">
 "format": <"json" | "xml", default: "xml">
 "mode": <"create" | "merge" | "replace", default: "merge">}

Did the JSON payload include a comma after the "data" string? It seems that the documentation is missing these, which results in invalid JSON.

 

A valid JSON-RPC parameter payload for the "load" method would loke something like

{"th": 42,
"data": "<config xmlns="http://tail-f.com/ns/config/1.0"><wrapper xmlns="urn:model"><name>create</name></wrapper></config>",
"mode": "create"}

Note that it should be possible to omit parameters with default values.

Cisco Employee

Re: Data Method Load example in JSON-RPC

Of course the XML data above needs to escape quotes, e.g. ..."data": "<config xmlns=\"...\">...</config>".

Beginner

Re: Data Method Load example in JSON-RPC

thank you for the response.

Yes, we did notice the missing comma's and have included those.

 

Do you have a working example with JSON as the data parameter payload?

Cisco Employee

Re: Data Method Load example in JSON-RPC

Given the following YANG model

module ex { 
namespace "urn:ex";
prefix ex;

leaf value { type int32; }
}

The following JSON-RPC payload loads config

{"jsonrpc": "2.0",
"method": "load",
"params":
{"th": 1,
"data": "{\"ex:value\":42}",
"mode": "create",
"format": "json"},
"id":1}