cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
800
Views
0
Helpful
4
Replies

Data Method Load example in JSON-RPC

lukepatrick
Level 1
Level 1

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"
 
 

 

4 Replies 4

perander
Cisco Employee
Cisco Employee

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.

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

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?

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}

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: