The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

error in posting a comment in any issue using HttpWebResponse or HttpClient

Tuhiram singh
October 1, 2021

Hi Team

Please help me my code are give below I am not able to post a comment in any issue . so please help me asap.

 

string result = string.Empty;
var jsonstring = @"{""update"":{""comment"": [ { ""add"": { ""body"": ""This is comment ""}}]}}";
try
{
//string restUrl = String.Format("{0}rest/api/2/issue/{1}/comment", Url, obj.issueid);
string postUrl = String.Format("{0}rest/api/2/issue/{1}", Url, obj.issueid);
HttpWebResponse response = null;
HttpWebRequest request = WebRequest.Create(postUrl) as HttpWebRequest;
request.Method = "PUT";
request.Accept = "application/json";
request.ContentType = "application/json";
request.Headers.Add("Authorization", "Basic " + GetEncodedCredentials(UserName, Password));
byte[] data = Encoding.UTF8.GetBytes(jsonstring);
using (Stream postStream = request.GetRequestStream())
{
postStream.Write(data, 0, data.Length);
}
using (response = request.GetResponse() as HttpWebResponse)
{
if (response.StatusCode == HttpStatusCode.Created)
{

}

}

0 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

TAGS
AUG Leaders

Atlassian Community Events