I am trying to create a new defect. I have to do it using REST API in my C# ASP.Net project. Below is the used URL:
qcbin/rest/domains/TESTDOMAIN/projects/TESTPROJECT/defects
Below is my request body :
<?xml version="1.0" encoding="UTF-8"?>
<Entity Type="defect">
<Fields>
<Field Name="priority">
<Value>3-High</Value>
</Field>
<Field Name="description">
<Value>test description</Value>
</Field>
<Field Name="name">
<Value>test with rest API</Value>
</Field>
<Field Name="creation-time">
<Value>2011-08-16 11:34:08</Value>
</Field>
</Fields>
</Entity>
I can successfully create the defect only if I do not use creation-time
in XML. May I know how to use columns that contain hyphen?
I have written the code on C#. Below is my C# code
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(HPALMUrl + "/rest/domains/" + HPALMDomain + "/projects/" + HPALMProject + "/defects/");
request.Method = "POST";
request.Accept = "application/xml";
request.ContentType = "application/xml";
authRequest.KeepAlive = true;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36";
request.CookieContainer = createSessionRequest.CookieContainer; //Authenticated cookie
using (var requestStream = request.GetRequestStream())
{
requestStream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
string responseText = string.Empty;
if (response.StatusCode == HttpStatusCode.OK)
responseText = "Update completed";
else
responseText = "Error in update";
I am facing this hyphen column problem when updating Test table column also. So, please let me know how to use hyphen contain column
Thanks in advance!