AnsweredAssumed Answered

How to set configuration attribute value using PI web API

Question asked by salte on Mar 30, 2015
Latest reply on Apr 17, 2015 by salte



I trying to work out how to set the value of a configuration item attribute from a C# client using the PI web API.


I can successfully set the value for an attribute which has a PI Point data reference using this code:


var client = new HttpClient(...) //more stuff to initalize http client
var webId = "theActualWebId";
HttpContent cont = new StringContent("{ \"Timestamp\":\"*\", \"Value\":1500 }", Encoding.UTF8, "application/json");
var request = string.Format(@"streams/{0}/value", webId );
var response = client.PostAsync(request, cont).Result;


But when I use the same code for setting a configuration attribute value the HttpResponseMessage.IsSuccessStatusCode will be false, and the .ReasonPhrase property will be "Conflict".

I've also tried changing the two last lines of code to:


var request = string.Format(@"attributes/{0}/value", webId );
var response = client.PutAsync(request, cont).Result;


but the reponse is the same.


The actual value of the configuration attribute is 500 with the timestamp "1970-01-01T00:00:00Z".


Is there an obvious reason why this is failing that I'm not getting?