Custom Command JSON Deserialization

I’m trying to make a custom command with the pattern ‘weather set ’ but I keep running into issues with json-as not being able to deserialize or serialize anything.

Error: Could not deserialize data {"Keyword":{"value":"stormy"}} to type WeatherSet. Make sure to add the correct decorators to classes.

namespace CmdArgs { @json export class WeatherSet { @alias("Keyword") keyword: FieldValue.Keyword = new FieldValue.Keyword(); } }

I followed the custom command examples in the v1.65.0 release and on GitHub. I messed around with the field’s capitalization and tried using FieldValue.Text or FieldValue.Keyword. At this point I’m considering just splitting the string by quotation marks - as hacky as that is.

Yes, it was due to a bug that I just made a fix for.
See this thread on how to fix your script:

1 Like

Thanks, Acci! I also ran into a problem with using my management token. I tried building 2 scripts to 2 different rooms and I got an error saying my token was invalid or expired.

If you’re working on the Test Realm, your token will expire the next time it’s copied over from the main Wolfery Realm, best bet is to get a token from Wolfery proper and then you can use the same token on the Test Realm the next time it’s copied.

1 Like

The management token doesn’t care about the number of rooms or scripts. So that shouldn’t be the issue.

Apart from what Xetem mentioned, other things to check are:

  1. Make sure you’ve copied the full token. Not all of it is visible in the GUI, so you should use the Copy to clipboard button:

  2. Check the token. The token should start with mgr. and be in total 36 characters long. Eg:

    mgr.AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH
    
  3. If you try to deploy to Wolfery, make sure you use the API URL for Wolfery (wss://api.wolfery.com) and not the test server:

    • In the mucklet.config.js file:
      realm: {
          apiUrl: "wss://api.wolfery.com"
      },
      
    • Or when passed using a command flag
      mucklet-script deploy --apiurl=wss://api.wolfery.com
      

Those were the things I could think of. Tell me if any of it works!

1 Like

Thanks. I finally got it to work. It seems on my machine if it uses the api url in the config I get ‘api service unavailable’ but works fine if I pass it as a command flag. And it doesn’t seem to recognize my token in my environment variables.

Oh! Good to know.
It is a new feature which I honestly haven’t had time to test thouroughly. :sweat_smile:

Just make sure you use upper-case U in "apiUrl" in the mucklet.config.js file. It is case sensitive.

I probably should make a validator, warning if a config field or value is invalid.