質問

I am unable to figure out how to update a milestone in baseCamp using the API. I'm able to do everything else (create, complete, uncomplete, and delete). But I'm stuck on updating. I keep getting a 406 error.

HttpWebRequest _request = (HttpWebRequest)WebRequest.Create(myURL);
_request.ContentType = "application/xml";
_request.Accept = "application/xml";
_request.Method = "POST";
_request.ServicePoint.Expect100Continue = false;
_request.Credentials = new NetworkCredential("xxxxMYKEYxxxx", "X");

byte[] byteData = UTF8Encoding.UTF8.GetBytes(RequestData);
_request.ContentLength = byteData.Length;
using (Stream stream = _request.GetRequestStream())
{
    stream.Write(byteData, 0, byteData.Length);
}

myURL is correct according to the api: https://mycompany.basecamphq.com/projects/8040830/calendar_entries/20940505.xml

And my request data looks correct:

<request>
 <calendar-entry>
  <title>My New Milestone - Renamed</title>
  <type>Milestone</type>
 </calendar-entry>
</request>

However, it always bombs with a "(406) Not Acceptable" error on

_request.GetResponse();

Can anybody see anything glaring? I'm new to the new REST api. I can do everything with calendar entries using the API. I just can't seem to figure out the updating. Any ideas?

役に立ちましたか?

解決

For the love of Pete!!!!!

Although the documentation clearly states that the update operation is a POST, it's actually a PUT. I love it when bad documentation costs me hours worth of time. At least this may help any of you out there who have the horrible habit of following directions.

Here is their documentation at http://developer.37signals.com/basecamp/calendar-entries.shtml

Update calendar entry
POST /projects/#{project_id}/calendar_entries/#{id}.xml
Modifies a calendar entry. Supplying a different value for ‘type’ can convert a calendar event to a milestone and vice versa. You can use this to shift the deadline of a single milestone, and optionally shift the deadlines of subsequent milestones as well

.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top