Call POST API from 3rd party system
AnsweredWe are implementing integration of our system with NX Optix API.
We are calling GET Api without any issue, they are working properly such as getEventRules, getCamerasEx ….
The issue is when we call POST APIs such as executeEventAction, saveEventRule, …
I am using account with administrator role and using following API for authentication from my code (getNonce, cookieLogin).
I send web API parameters as JSON object in request body as following:
executeEventAction: (Post request)
Request header: X-Runtime-Guid = UUID value
URL: https://(Our System UUID).relay.vmsproxy.com/api/executeEventAction
Parameters as JSON object and Encoding.UTF8 in body
{
"actionType":"SendMailAction",
"EventState":"active",
"resourceIds":[" UUID "],
"actionParams":{
"emailAddress":" test email address..."
}
}
Response is:
"{\"error\":\"0\",\"errorString\":\"\",\"reply\":null}" and I have not received any email and cannot see in event log.
saveEventRule : (Post request)
Request header: X-Runtime-Guid = UUID value
URL: https://(Our System UUID).relay.vmsproxy.com/ec2/saveEventRule
Parameters as JSON object and Encoding.UTF8 in body
{
"id": "1ea3a29e-a3fa-45d7-9b32-dd5d2323d336",
"eventType": "cameraMotionEvent",
"eventState": "Active",
"system": false,
"eventResourceIds": [ "027171b0-c5a9-96c6-4456-4c7dbb7171b0"],
"eventCondition": {
"eventTimestampUsec": 0,
"eventType": "undefinedEvent",
"metadata": {
"allUsers": false,
"level": 0
},
"omitDbLogging": false,
"reasonCode": "none"
},
"aggregationPeriod": 3600,
"actionType": "sendMailAction",
"disabled": false,
"actionParams": { "emailAddress": " test email address " },
"actionResourceIds": []
}
Response is:
StatusCode: 500, ReasonPhrase: 'Internal Server Error'
I set values for required parameters as mentioned on website.
What is the issue and how to fix it and how can we track it (event log, audit ….)?
Could we get code examples how to call programmatically NX Optix Web APIs (POST) from 3rd party system?
-
We have a node.js library, that executes a few POST requests including saveEventRule. Please, check here: https://support.networkoptix.com/hc/en-us/articles/360026544554-Node-js-Integration-Library
But I have a couple of comments/questions here:
1) What are you using to make requests? If you are making them using javascript via browser, POST requests will not work due to CORS protection policies.
2) If you are not using the browser, can you consider using Digest authentication?
3) The method executeEventAction is highly not recommended for manual execution. To trigger events in the system - create rules for Generic Event using saveEventRule, and then send Generic Events.
0 -
I am using C# windows application and calling NX Optix API from C# code.
I am calling executeEventAction because I only want to execute action (send email, do recording ,.....) that is not related to any event. so I do not want to use EventRule which inforce me to define event first.
SaveEventRule API returns "Internal server error"
0 -
The system doesn't support just actions without events - it cannot send an abstract email, it needs an Event to fill the template.
>> SaveEventRule API returns "Internal server error"
Can you copy-paste a code sample that returns "Internal server error"?
Also, this thread: https://support.networkoptix.com/hc/en-us/community/posts/360049203514-Getting-a-400-Bad-Request-error-when-adding-a-new-event-rule-for-http-request-as-an-action-using-ec2-saveEventRule-API-endpint- and comments there might be helpful in checking the issues.
0 -
The system doesn't support just actions without events:
I followed api documentation.
executeEventAction does not require an event as written in API documentation
Parameters:
-actionType (not optional)
-EventState
-resourceIds (not optional)
-params
-runtimeParams
-ruleId (optional)
-aggregationCount
>> SaveEventRule API returns "Internal server error"
saveEventRule : (Post request)
Request header: X-Runtime-Guid = UUID value
URL: https://(Our System UUID).relay.vmsproxy.com/ec2/saveEventRuleParameters as JSON object and Encoding.UTF8 in body
{
"id": "1ea3a29e-a3fa-45d7-9b32-dd5d2323d336",
"eventType": "cameraMotionEvent",
"eventState": "Active",
"system": false,
"eventResourceIds": [ "027171b0-c5a9-96c6-4456-4c7dbb7171b0"],
"eventCondition": {
"eventTimestampUsec": 0,
"eventType": "undefinedEvent",
"metadata": {
"allUsers": false,
"level": 0
},
"omitDbLogging": false,
"reasonCode": "none"
},
"aggregationPeriod": 3600,
"actionType": "sendMailAction",
"disabled": false,
"actionParams": { "emailAddress": " test email address " },
"actionResourceIds": []
}
Response is:
StatusCode: 500, ReasonPhrase: 'Internal Server Error'0 -
Hi Rodan,
I get 200 at my test server sending post request withs this very JSON object as a payload.
Using both local connection and relayed cloud system id address.
It seems that you encounter some internal server issue we would like to investigate.
Would you agree to proceed with the more thorough investigation in a form of the support ticket? It might require adding our engineer as a system user and potentially providing remote access to the target Server OS.
If you response positively, I will issue a support ticket on your behalf.
0 -
Hello Rodan,
The executeEventAction function is proprietary. It was made available by mistake and is not available in the latest API documentation. Read this thread for more details
https://support.networkoptix.com/hc/en-us/community/posts/360043672414--api-executeEventAction
This makes me think, you are not using the latest version of the Server. Which version are you using?
> Could we get code examples how to call programmatically NX Optix Web APIs (POST) from 3rd party system?
Could you please give us more details on your scenario? What is your objective? What are you trying to achieve? What is the expected final result?
0 -
Hi Sergey,
Thank you for your reply.
Yes, please proceed it with support ticket.
0 -
Hi Andrey,
I am trying to use POST APIs and I started with two of them executeEventAction and SaveEventRule and both of them are not working with me.
for example of our integration, we want to call Camera Post Api (manualCamera/add) in order to add camera from our system programmatically then define its event rules through SaveEventRule.
0 -
Hi,
Please, DO NOT TRY using executeEventAction function. It won't work. Just forget this function.
Mind the function names are case-sensitive. There is no SaveEventRule function, butsaveEventRule.> we want to call Camera Post Api (manualCamera/add) in order to add camera from our system programmatically
Here is the detailed article. Please, read it carefully.
https://support.networkoptix.com/hc/en-us/articles/360026015473-Adding-a-camera-or-a-RTSP-stream-using-API> then define its event rules through SaveEventRule.
Here is the post about creating rules over API.
https://support.networkoptix.com/hc/en-us/community/posts/360042150894-How-create-Event-through-APIs-and-execute-them-And one more with grater details.
https://support.networkoptix.com/hc/en-us/community/posts/360042988034-How-to-use-execHttpRequestAction-and-it-complete-functionality
Rodan, could you please indeed answer questions asked as much detailed as possible. It is very important to understand your environment and specific scenario. Otherwise, without requested info it simply impossible for us to help you anyhow.
Which version of the Server are you using?
What is the specific rule type are you facing problem with?
Have you tried to create a rule in CLI just in bash and curl?0 -
Rodan,
I created a support ticket. Please, check your mailbox.
The solution will be posted here as soon as it is found during investigation.
0 -
Hi Andrey,
Okay I will not use executeEventAction anymore, and I am using
saveEventRulenot SaveEventRule from my .net code.Which version of the Server are you using?
System version 4.1.0.31398
What is the specific rule type are you facing problem with?I am trying to create event rule programmatically (.net code) as following: send an email (actionType: sendMailAction) when system receives motion event from camera (eventType: cameraMotionEvent).I will check your URL references.Have you tried to create a rule in CLI just in bash and curl?No, just call API from .net code0 -
Hi @...,
Our team is awaiting to your reply in the support ticket that has been created for this matter.
Can you please reply on this ticket? Thank you!0 -
Hi @...,
We have not heard back from you in a while, so we are going to assume your question has been answered and set the support ticket to closed. Please note that you can reopen this ticket and continue to receive support from us by simply replying to the corresponding email.
0
Please sign in to leave a comment.
Comments
13 comments