Start/Stop recording schedule API
AnsweredHi, I am trying to implement start/stop recording schedule of specific camera in my application. I followed the directions in one of the support forms like below: Created the Ajax request object and added saveCameraAttributes URL with Post JSON . I am getting still 401 unauthrized error. I am able to export/view the archive of the camera passing auth parameter(with base64 encoded value - it didn't require to enter username/password) in the URL. But not able to implement start/stop recording schedule. Please let me what am i missing to use this feature with passing authorization to avoid 401 error.
Ex:
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST",http://10...:7001/ec2/saveCameraUserAttributes, true);
xmlHttp.setRequestHeader('content-type', 'application/json');
xmlHttp.setRequestHeader('Authorization', 'Basic=(username, password)' );
xmlHttp.send(postJSON);
Thanks.
-
There are two authentication methods which work for Ajax requests: cookie-based and URL-based, server API documentation has detailed information on both of them.
Also, digest is supported, but it is really hard to use in the browser environment.
1 -
Hi,
Thank you for your reply. I am using URL based authentication like mentioned in the document. First i am calling getCamerasEx - to get the cameraids - passing the auth parameter in the url - it's working fine look below the screen shot. Took the camera id from the getCamerasEx method and updating the schedule parameter and post it using saveCameraUserAttributes call with same URL based digest authenthication .. Not sure why am i getting not authorized only for saveCameraUserAttributes call.
Thanks.
0 -
Hi,
Does the saveCameraUserAttributes allow to pass auth parameter in the URL like other methods (getCamerasEx...) are doing like above in mentioned screenshot ?
Thanks.
0 -
Yes, but for POST requires another authentication key need be generated - using POST instead of GET as 'method' parameter
0 -
Means I need to make getNonce call again using post and get the digest key and pass it to the URL ?
0 -
No, you can use the same nonce.
When you calculate partial_ha2 for your auth key :
partial_ha2 = md5_hex(method + ":")Use method='POST' instead of 'GET'
0 -
Hi,
Thank you for the quick response and detailed explanation.
Got it what you said. I generated authentication key using the method POST. I am seeing the difference between GET authentication key and POST authentication key.
I pasted the screenshot below : saveCameraUserAttributes - passing the post auth key in the URL and still i am receiving wrong digest.
Please let me know your suggestions.
Thanks.
0 -
Hi,
I tried calling "getnonce" again like below and tried that POST method key .. passing that auth parameter. Still i am getting 401 error. Let me know what else am i missing to make the successful saveCameraUserAttributes call?
var xmlHttp2 = new XMLHttpRequest();
var nonceResp = xmlHttp2.responseText;
var nonceResp = eval('(' + nonceResp + ')');
log("getNonce resp=" + nonceResp.reply);
var nonceValue = nonceResp.reply.nonce;
var realmValue = nonceResp.reply.realm;
var postdigest = digest('test','test',realmValue,nonceValue,'POST');
var saveCameraEx = serverURL +"/ec2/saveCameraUserAttributes?auth="+postdigest;
var xmlHttp1 = new XMLHttpRequest();
xmlHttp1.open("POST",saveCameraEx, true);
xmlHttp1.setRequestHeader('content-type', 'application/json');
xmlHttp1.send(postJSON);function digest(user, passw, realm, nonce, method)
{
var digest = md5_hex(user + ":" + realm + ":" + passw);
var partial_ha2 = md5_hex(method + ":");
var simified_ha2 = md5_hex(digest + ":" + nonce + ":" + partial_ha2);
var auth_digest = Base64.encode(user + ":" + nonce + ":" + simified_ha2);
return auth_digest;
};Thanks
0 -
Any suggestions for the above issue ? I didn't receive any reply for my above post.
Like you mentioned generated POST key and pass that key in the URL based authentication with auth= for saveUserCameraAttributes.
0 -
Hi,
If the saveUserCameraAttributes call doesn't accept the URLBased Authentication auth parameter , please let me know. I will update in my company .
Please reply whether it's possible or not.
Thanks.
0 -
Hi Sakunthala, we are trying to figure out what is wrong with that method. Please, give us a couple of days to come up with solution
0 -
Hi Sakunthala, we checked once again. Unfortunately, POST requests are not supported from javascript (from browser), only backend can do such requests.
We hope to fix the problem in the next releases
0 -
Hi Evgeny,
Thank you. Really appreciated !!!
-Sakunthala.
0 -
Is your system cloud-connected?
0 -
No. I didn't create any cloud account yet.
0
Please sign in to leave a comment.
Comments
15 comments