Start/Stop recording schedule API

Answered

Comments

15 comments

  • Avatar
    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.

     

  • Avatar
    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.

     

     

  • Avatar
    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.

       

  • Avatar
    Evgeny Balashov

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

  • Avatar
    Sakunthala Kumaresh

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

  • Avatar
    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'

  • Avatar
    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.

     



     

     

  • Avatar
    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

  • Avatar
    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. 

     

     

     

     

  • Avatar
    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.

  • Avatar
    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

  • Avatar
    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

  • Avatar
    Sakunthala Kumaresh

    Hi Evgeny,

    Thank you. Really appreciated !!!

    -Sakunthala.

  • Avatar
    Evgeny Balashov

    Is your system cloud-connected? 

  • Avatar
    Sakunthala Kumaresh

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

Please sign in to leave a comment.