1 to 6 of 6
I have been attempting to add task notes in C# and am always getting a Error 400 Bad Request. I have gone through all the forum posts related to this and believe I am formulating the request correctly. Can some have a look and tell me where its going wrong. I have not problems sending a GET request its just POST and PUT.
Here is the code.
string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?><tasknote><taskid>11089</taskid><note>Test note</note></tasknote>";
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest) System.Net.WebRequest.Create(URI);
req.Accept = "application/xml";
req.ContentType = "application/xml";
req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(auth)));
req.Method = "POST";
// Add parameters to post
byte data = System.Text.Encoding.UTF8.GetBytes(xml);
req.ContentLength = data.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(data, 0, data.Length);
// Do the post and get the response.
System.Net.WebResponse resp = req.GetResponse();
if (resp == null) return null;
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
Every failed request is returned with one or more verbose error messages within the response body. The response body also contains a specific error code related to the API.
Can you give me more information about the errors you receive in the response body when you run that request?
It looks like it could be a validation error. The tasknote resource documentation specifies that each new task note must specify a value for the public field (whether the task note is visible to executive-level users). That field does not appear to be present in the XML you are submitting to the server.
I would have assumed that if you offer a default value of 'f' then it would not be required. But I tried that and it didn't work but I have since run Fiddler and determined that the issue was the task number. I assumed that the task number would relate the task number shown in intervals. But after doing a task list GETI can see that the numbers are different and obviously a global ID number that intervals is assigning it.
This leads to another question. How do I search for a task using the ID shown on the tasks Intervals page. I could not see anything in the task API definition that represents this.
Its ok I can see the localid filter option will give me that.
Looks like you've figured it out, but for any others:
The Intervals API uses id fields for the purposes of filtering (for example, if a resource has a clientid field, it refers to the id of a client resource).
There are several resources that use a localid field for the purposes of identifying the resource within the Intervals web application. However, it is used only for that, and is not used for foreign-keyed relationships between resources. You can think of it as you would a title field: useful for identification, but not for the purposes of defining relationships between objects.
1 to 6 of 6
Comments are closed.
For more Intervals help documentation, please visit help.myintervals.com