How to run cli command line "show confd-state" by using maapi function

Hi Team,

I want to run cli command line “show confd-state”, “show running-config” in my process. It seems that maapi_cli_cmd or maapi_cli_cmd2 may suffice, the code snippet is shown as below:

maapi_cli_printf(action_socket, uinfo->usid, "output of show running-config);

rc = maapi_cli_cmd2(action_socket, uinfo->usid, "show running-config", 1024, MAAPI_CMD_NO_FULLPATH);
if(CONFD_OK != rc) {
    TRACE_WRITE("maapi_cli_cmd return error:%d confd_errstr:%s confd_errno:%d \n", rc, confd_strerror(confd_errno), confd_errno);
}

But it is return with:
DBG:maapi_cli_cmd2 return error:-1 confd_errstr:CLI command error confd_errno:59

output of show running-config
show running-config
--------------------^
syntax error: element does not exist.

Please kindly told me whether the maapi function is called improperly?Or Is there a better way?
Thanks.

I think the reason for your error is the third argument to maapi_cli_cmd2() (size). It should be the length of the CLI-command string but in your case it’s 1024.