pushdata webapi

Started by samuelet, August 26, 2022, 01:37:08 PM

Previous topic - Next topic

samuelet

Hi,
How can i use curl to push dci data on remote netxms host?
From changelog i see push dci via webapi feature is already implemented (even if it's not documented), but i always get 404 Not Found -> error 46
I also put debug to 6, but i get no log about webapi.

This is an example:

/usr/bin/curl -u admin:XXXXXX -H "Accept: application/json" -H "Content-Type:application/json" --data '{"login":"admin", "password":"XXXXX","data": {"node",1234,"OK" }}' -v "http://x.x.x.x:8080/webapi/pushData" 

> User-Agent: curl/7.64.0
> Accept: application/json
> Content-Type:application/json
> Content-Length: 41
>
* upload completely sent off: 41 out of 41 bytes
< HTTP/1.1 404 Not Found
< Content-Type: application/json;charset=utf-8
< Date: Fri, 26 Aug 2022 10:25:21 GMT
< Accept-Ranges:  none
< Server: Restlet-Framework/2.4.3
< Content-Length: 43
<
* Connection #0 to host X.X.X.X left intact
{"description":"Internal error","error":46}



Filipp Sudanov

There are two options - to send value for a single DCI or for a number of DCIs (array is used in this case);

One value:
{
      nodeId : 10,
      dciId : 20,
      value : "Value"
}


Or, alternatively node name and DCI name (parameter name) can be used:
{
      nodeName : "Node name",
      dciName : "DCI name",
      value : "Value"
}


When sending multiple values:
data :
[
   {
      nodeId : 10,
      dciId : 20,
      value : "Value"
   },
   {
      nodeName : "Node name",
      dciName : "DCI name",
      value : "Value"
   }
]

samuelet

Thanks, it's now clear how to send value but unfortunately i still cannot authenticate the POST with the netxms api.
I also tried with the sessesionhandler cookie as explained here:
https://wiki.netxms.org/wiki/Web_service_API
In my case, i've no proxy in front of it, and with the jetty requestlog i don't see any error except "internal error" .
I'm authenticating with the "admin" user (full rights).
Is there something that i missing to enable?

samuelet

i found that i was using a wrong api url (retrived from github): /push-data and not /pushData
Now it works.