API question on tags

In the rest API docs, there are the following two lines:

      put          /items/{itemname: [a-zA-Z_0-9]*}/tags/{tag: [a-zA-Z_0-9]*}          
      delete          /items/{itemname: [a-zA-Z_0-9]*}/tags/{tag: [a-zA-Z_0-9]*}

When trying to call these with respective PUT and DELETE, I am receiving a 405 method not allowed.

Is there a particular content-type or allowed-type header that needs to be set? Are tags fully implemented in the API?

Thanks,
Jim

1 Like

If you have SSL turned on make sure you are accessing the correct port (8443 as opposed to 8080).

According to the wiki, your URL should look like: http://localhost:8080/rest/items/Temperature_FF_Office/state with an encoding of text/plain and the new state as a plain string argument in the body for PUT. You can achieve the same thing using a GET with a URL like this: http://localhost:8080/CMD?Temperature_FF_Office=12.3

The wiki doesn’t say anything about DELETE so I can’t say what it expects. I’ve only used the GET with the REST API so have little experience with the other verbs.

What docs are you looking at that list those lines?

Rich

Note that changing items (and adding deleting tags is a change as well) is only possible for items that are stored in the database (and thus are writable) and NOT for items from *.items files.
So if you add items through the REST API, you should also be able to PUT and DELETE tags on them.

Regards,
Kai

1 Like

Thanks for the replies @rlkoshak and @Kai. This particular set of docs is the live api documentation found by hitting the /doc URL. They are listed under items.

Kai, that is an important distinction that I missed. This is a 2.0 binding (Network to be exact) created through PaperUI, but the item definition is in a .items file. Is there any provision to alter tags statically in the items file? The entry looks like this:

Switch JimS5 { channel="network:device:141e3618:online" }

Alternately, if I remove the items file and use the API to create the item, then you are saying the tags can be manipulated, correct?

Thanks
Jim

Yes, simply use square brackets:

Switch JimS5 [ "myTag1", "myTag2" ] { channel="network:device:141e3618:online" }
```

[quote="xsnrg, post:5, topic:1919"]
Alternately, if I remove the items file and use the API to create the item, then you are saying the tags can be manipulated, correct?
[/quote]

Correct!

Works perfectly. Thanks for the clarification Kai!

Jim

1 Like