Page 1 of 1

Possible bug in /api/updatedevicemetadata

Posted: Fri Sep 11, 2015 4:35 pm
by kmeurer

Working through the API, and I can't get UpdateDeviceMetaData to work. It returns success, but does not change the name or location.

Thanks for the help on this. The API is very nice to use.

Code: Select all

using System;
using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

class MainClass
   const string zcommandUrl = "";

   public static int Main(string[] args)
      // this is to allow the default certificate on the ZCommand module to pass. otherwise we'll keep getting exceptions.
         = ((sender, cert, chain, errors) => cert.Subject.ToLower().Contains("zcommand"));

      WebClient ZCommandWebClient = GetAuthenticatedWebClient();
      var form = JsonConvert.SerializeObject(new { name = "Office Tester", location = "In the Office" });
      var response = ZCommandWebClient.UploadString(string.Format("{0}/api/updatedevicemetadata/4", zcommandUrl), form);

      Console.WriteLine("Response: {0}", response);

      return 0;

   private static WebClient GetAuthenticatedWebClient()
      WebClient webClient = new WebClient();
      webClient.Headers.Set(HttpRequestHeader.UserAgent, "zcommand");

      var form = JsonConvert.SerializeObject(new { Username = "admin", Password = "admin" });
      var response = webClient.UploadString(zcommandUrl + "/api/tokenauth", form);
      var obj = JObject.Parse(response);

      webClient = createAuthorizedWebClient(obj["responseObject"].ToString());
      return webClient;

   private static WebClient createAuthorizedWebClient(string token)
      WebClient webClient = new WebClient();
      webClient.Headers.Set(HttpRequestHeader.UserAgent, "zcommand");
      webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
      webClient.Headers.Add(HttpRequestHeader.Authorization, "Token " + token);
      return webClient;


Re: Possible bug in /api/updatedevicemetadata

Posted: Mon Sep 14, 2015 6:16 pm
by admin
Can you post the complete response?

Re: Possible bug in /api/updatedevicemetadata

Posted: Mon Sep 14, 2015 6:43 pm
by kmeurer
It appears to have been accepted, but it does not make the change. I can change it with the admin panel just fine.

Code: Select all

   "responseObject": {
                  "cssClass":"zwavedevice device has-level listening  binary-level switch binary-switch",
                  "deviceType":"On/Off Power Switch Device Type",
                  "name":"Office Test",
                  "deviceModel":"Aeon Labs DSC06106-ZWUS Binary Switch"

Re: Possible bug in /api/updatedevicemetadata

Posted: Sun Nov 15, 2015 11:06 am
by admin
This issue has been resolved in the latest release of Z-Command.