fogbugzfogbugz-api

FogBugz XML API (Cases:)


I'm consuming the FogBugz XML API but I have a problem. I'm able to create new cases, open created cases, search cases etc through my app. The problem consist of when getting the payload I can get the body of the case using the following piece of code:

        string fbToken = LogOnFogBugz();
        string param = "";

        param += "cmd=search";
        param += "&token=" + fbToken;
        param += "&q="+ "appID["+appID+"]";
        param += "&cols=sTitle,sStatus,sLatestTextSummary";

        HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(fbUrl + param);
        httpWebRequest.Method = WebRequestMethods.Http.Post;
        httpWebRequest.Accept = "application/xml";
        httpWebRequest.ContentLength = 0;

        HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse();
        StreamReader streamReader = new StreamReader(response.GetResponseStream());
        XDocument doc = XDocument.Load(streamReader);

 var cases = from c in doc.Descendants("case")
                    select new
                        {
                            CaseNumber = c.Attribute("ixBug").Value,
                            CaseTitle = (string)c.Element("sTitle"),
                            CaseStatus = (string)c.Element("sStatus"),
                            CaseText = (string)c.Element("sLatestTextSummary")
                        };

but If I edit the case and add text to it, I only get last entered text as (sLatestTextSummary) implies.

How can I get the whole text from a case using the XML API.

Example:

Opened by xxx xxx 4/4/2012 (Today) 10:31 AM ------------------------->Blah Blah Blah

Assigned to xxx xxxx by xxx xxx 4/4/2012 (Today) 10:31 AM

Edited by xxx xxx 4/4/2012 (Today) 2:00 PM ---------------------------->New text.

I'm only getting {new text}.

Thanks in advance.

Ed


Solution

  • You want to include events as one of your cols arguments. Then for each case you will also have to iterate over the events to get the text out of them.