Skip to main content

Start/Stop recording schedule API

Answered

Comments

15 comments

  • Evgeny Balashov

    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
  • Sakunthala Kumaresh

    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
  • Sakunthala Kumaresh

    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
  • Evgeny Balashov

    Yes, but for POST requires another authentication key need be generated - using POST instead of GET as 'method' parameter

    0
  • Sakunthala Kumaresh

    Means I need to make getNonce call again using post and get the digest key and pass it to the URL ? 

    0
  • Igal

    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
  • Sakunthala Kumaresh

    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
  • Sakunthala Kumaresh

    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
  • Sakunthala Kumaresh

    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
  • Sakunthala Kumaresh

    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
  • Evgeny Balashov

    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
  • Evgeny Balashov

    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
  • Sakunthala Kumaresh

    Hi Evgeny,

    Thank you. Really appreciated !!!

    -Sakunthala.

    0
  • Evgeny Balashov

    Is your system cloud-connected? 

    0
  • Sakunthala Kumaresh

    No. I didn't create any cloud account yet.

    0

Please sign in to leave a comment.