I have successfully managed to sign-in/authenticate with my ALM instance using the Rest API, but I am now confused on what I should be doing to create a new test set.
private string CreateTestSetURL = "{0}rest/domains/{1}/projects/{2}/test-sets";
// Parameters : 0 = Open Date, 1 = Description, 2 = parent, 3 = Name.
private const string TestSetsXML = "<Entity Type=\"test-set\">" +
"<Fields>" +
"<Field Name=\"status\"><Value>Open</Value></Field>" +
"<Field Name=\"open-date\"><Value>{0}</Value></Field>" +
"<Field Name=\"subtype-id\"><Value>hp.pc.test-set.performance</Value></Field>" +
"<Field Name=\"description\"><Value>{1}</Value></Field>" +
"<Field Name=\"parent-id\"><Value>{2}</Value></Field>" +
"<Field Name=\"name\"><Value>{3}</Value></Field>" +
"</Fields>" +
"</Entity>";
string requestURL = String.Format(TestSetsURL, baseRequestURL, qcSettings.QCDomain, qcSettings.QCProject);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(requestURL));
string xml = String.Format(TestSetsXML, "2015-12-17", "test please ignore", parent, "TestPleaseIgnore");
byte[] Requestbytes = Encoding.UTF8.GetBytes(xml);
//request.
request.CookieContainer = authenticationCookieContainer;
request.Method = "POST";
request.ContentType = "application/xml";
request.Accept = "application/xml";
request.ContentLength = Requestbytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(Requestbytes, 0, Requestbytes.Length);
requestStream.Close();
var response = request.GetResponse();
var responseStream = response.GetResponseStream();
The result is this error : "The remote server returned an error: (400) Bad Request."
Probably a couple of questions:
UPDATE: I have tried Barneys suggestion, but I am still getting (400) Bad Request.
Question updated with changes.
You have to give the server two important things (data = your_Xml and headers=for authorization) Then you should have no problem ;) Anyway is the error code 400 or 500? Usually 500 is a bad request / 400 is bad authorization
Can it be that your user have only read rights and it is not able to create?
Hope that you solved in the meanwhile your issue ;)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.