want to add new coment on ticket using assembla API, However gettig "Protocol Error" as return msg

17 views
Skip to first unread message

Puneet Mongia

unread,
Feb 12, 2015, 5:42:03 AM2/12/15
to assembla...@googlegroups.com
want to add new coment on ticket using assembla API, However gettig "Protocol Error" as return msg


string postURL = AssemblaUrls.TicketComment.Replace("[space_id]", SpaceName).Replace("[ticket_number]", ticketNumberToUpdate.ToString());
                    var request = (HttpWebRequest)WebRequest.Create(postURL);
                    request.PreAuthenticate = true;
               
                    request.Headers.Add("X-Api-Key: " + AppSecrete.CodeReviewApiKey);
                    request.Headers.Add("X-Api-Secret: " + AppSecrete.CodeReviewApiKeySecret);
                    request.Method = WebRequestMethods.Http.Post;                   
                    request.Accept = "application/xml";
                    request.ContentType = "application/xml";

                    string postData = "<ticket_comment><comment>" + comment + "</comment>";
                    postData = postData + "</ticket_comment>";//relationship Value    Relationship 0    Parent,1    Child,2    Related,3    Duplicate
                    request.ContentLength = postData.Length;
                    StreamWriter postStream = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
                    postStream.Write(postData);
                    postStream.Close();

                    try
                    {
                       
                        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                        using (StreamReader sr = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
                        {
                            // string xmltext = Convert.ToString(sr.ReadToEnd());
                            ///XDocument xd = XDocument.Parse(xmltext);
                        }
                        return "Updated successfully";
                    }

Stanislav Kolotinskiy

unread,
Feb 12, 2015, 6:03:42 AM2/12/15
to assembla...@googlegroups.com
Hi Puneet,

I have some questions:
1. What's the value of AssemblaUrls.TicketComment ?
2. Are you sure that PreAuthenticate is needed? Basically, auth is being made via request headers
3. What's the final value of postData? Is it valid XML?
4. What's the response status?

Regards,
Stanislav
--
You received this message because you are subscribed to the Google Groups "Assembla API Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to assembla-api-d...@googlegroups.com.
To post to this group, send email to assembla...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages