How to enable jsonrpc in confd

Is there any specific steps that need to be done (e.g. confd.conf settings) to enable ‘http:///jsonrpc’ interface?

I have webui enabled via confd.conf






With the above

$ curl \
        -X POST \
        -H 'Content-Type: application/json' \
        -d '{"jsonrpc": "2.0", "id": 1, \
        "method": "login", \
        "params": {"user": "root", \
        "passwd": "root"}}' \

<!DOCTYPE html>
<title>404 Not Found</title>
<h1>Not Found</h1>
The requested URL /jsonrpc was not found on this server.
<address> undefined Server at localhost:8008 </address>

In examples/json_rpc/common_flow I see following files are present in docroot

$ tree docroot/
___ confd
___ ___ Comet.js
___ ___ example.js
___ ___ index.js
___ ___ JsonRpc.js
___ ___ lib
___     ___ bluebird
___     ___ ___ bluebird.js
___     ___ jquery
___     ___ ___ jquery.js
___     ___ lodash
___         ___ lodash.js
___ index.html
___ login
___ ___ lib
___ ___ ___ jquery.js
___ ___ login.css
___ ___ login.js
___ login.html

Are these files needed in target also to support jsonrpc?


docroot files are an example implementation of “web-app/stack” that uses JSON-RPC, but as such are NOT required for JSON-RPC API to work e.g. via using curl client to talk to JSON-RPC ConfD server…
When you see sibling directory examples.confd/json_rpc/webui, it contains completely different web-app stack in docroot (after build).

Hard to say what’s wrong in your case, i dont have experience w.g. with proxy settings - what other parts you do (not) have e.g. regarding AAA? Try building from the codebase/confd.conf off of existing examples (common_flow of webui) and see what change causes it to break…
(you can ignore/skip docroot for either example, just start confd with the confd.conf, and try using curl e.g. according to ConfD user guide’s JSON-RPC chapter.

Thanks @josephm . Actually the file name docroot/confd/JsonRpc.js was throwing me off. And my js skills are too poor to make an informed judgement.

Anyways now I would try to create a minimal working example with confd for json rpc.


No worries, sometimes the names of files might not be very descriptive, and can easily lead to confusion :slight_smile:

ConfD’s examples are sort of “full stack”, including ConfD as JSON-RPC server, but also JS files/frontend web files as JSON-RPC client (docroot). Funnily both are served by ConfD’s web server in the examples.