Xively Channel Tags

Does anybody know how to update Channel Tags in Xively?
I know how to do it for the Feed, but for Channels I couldn’t find any docs.

Open up the channel so you can see the graph, and then click Edit in the bottom left hand corner.

thanks, but sorry, I want my Imp to do that. :>

Doh! Sorry. Given how the XIvely API works, I’ll bet you can just pass it in the channel json, but you are right, there is not much about tags in the API docs. Here is a page with some tag information…

https://xively.com/dev/docs/api/data/read/all_feeds/

I really need to write a REST API so I understand them better. I’ll try playing with the channel JSON and see if I can get it to work.

Yeah, that works. Update the channel class in the Xively namespace to:

`
class Xively.Channel {
id = null;
current_value = null;
mytag = “”;

constructor(_id)
{
    this.id = _id;
}

function Set(value, tag) { 
	this.current_value = value;
    this.mytag = tag;
}

function Get() { 
	return this.current_value; 
}

function ToJson() { 
	local json = http.jsonencode({id = this.id, current_value = this.current_value, tags = this.mytag});
    return json;
}

}
`

And then you can send the tags like this:
channel1.Set(value, "My new channel tag");

thanks, joel.
I don’t know which library you used, but I think I know now how it has to be constructed .

Sorry, here is the whole thing from one of my agents… its the code @beardedinventor wrote:

`APIKEY <- “”;

Xively <- {}; // this makes a ‘namespace’

class Xively.Client {
ApiKey = null;
triggers = [];

constructor(apiKey) {
	this.ApiKey = apiKey;
}

/*****************************************
 * method: PUT
 * IN:
 *   feed: a XivelyFeed we are pushing to
 *   ApiKey: Your Xively API Key
 * OUT:
 *   HttpResponse object from Xively
 *   200 and no body is success
 *****************************************/
function Put(feed){
	local url = "https://api.xively.com/v2/feeds/" + feed.FeedID + ".json";
	local headers = { "X-ApiKey" : ApiKey, "Content-Type":"application/json", "User-Agent" : "Xively-Imp-Lib/1.0" };
	local request = http.put(url, headers, feed.ToJson());

	return request.sendsync();
}

/*****************************************
 * method: GET
 * IN:
 *   feed: a XivelyFeed we fulling from
 *   ApiKey: Your Xively API Key
 * OUT:
 *   An updated XivelyFeed object on success
 *   null on failure
 *****************************************/
function Get(feed){
	local url = "https://api.xively.com/v2/feeds/" + feed.FeedID + ".json";
	local headers = { "X-ApiKey" : ApiKey, "User-Agent" : "xively-Imp-Lib/1.0" };
	local request = http.get(url, headers);
	local response = request.sendsync();
	if(response.statuscode != 200) {
		server.log("error sending message: " + response.body);
		return null;
	}

	local channel = http.jsondecode(response.body);
	for (local i = 0; i < channel.datastreams.len(); i++)
	{
		for (local j = 0; j < feed.Channels.len(); j++)
		{
			if (channel.datastreams[i].id == feed.Channels[j].id)
			{
				feed.Channels[j].current_value = channel.datastreams[i].current_value;
				break;
			}
		}
	}

	return feed;
}

}

class Xively.Feed{
FeedID = null;
Channels = null;

constructor(feedID, channels)
{
    this.FeedID = feedID;
    this.Channels = channels;
}

function GetFeedID() { return FeedID; }

function ToJson()
{
    local json = "{ \"datastreams\": [";
    for (local i = 0; i < this.Channels.len(); i++)
    {
        json += this.Channels[i].ToJson();
        if (i < this.Channels.len() - 1) json += ",";
    }
    json += "] }";
    return json;
}

}

class Xively.Channel {
id = null;
current_value = null;
mytag = “”;

constructor(_id)
{
    this.id = _id;
}

function Set(value, tag) { 
	this.current_value = value;
    this.mytag = tag;
}

function Get() { 
	return this.current_value; 
}

function ToJson() { 
	local json = http.jsonencode({id = this.id, current_value = this.current_value, tags = this.mytag});
    //server.log(json);
    return json;
}

}

client <- Xively.Client(APIKEY);
probe1 <- “”;
probe2 <- “”;
device.on(“Xively”, function(v) {
channel1 <- Xively.Channel(“Grill_Temperature”);
channel1.Set(v.probe1temp, “Grill”);
probe1 = v.probe1temp;
channel2 <- Xively.Channel(“Food_Probe_Temperature”);
channel2.Set(v.probe2temp, “Probe”);
probe2 = v.probe2temp;
channel3 <- Xively.Channel(“Grill_Temp_Reference”);
channel3.Set(v.probe1reftemp, “Reference”);
channel4 <- Xively.Channel(“Food_Probe_Temp_Reference”)
channel4.Set(v.probe2reftemp, “Reference”);
feed <- Xively.Feed(“1990153056”, [channel1, channel2, channel3, channel4]);
client.Put(feed);
});`