1

我可以毫无问题地获得待办事项,但是当我在大本营发布待办事项时,我得到 403 禁止

这是我的代码

代码

var client = new RestClient()
{
    BaseUrl = "https://basecamp.com/" + accountId + "/api/v1/projects/" + projectId + "/todolists/" + todolistId + "/todos.json"
};

string baseCampClientId = WebConfigurationManager.AppSettings["bcClientId"];
string baseCampClientSecret = WebConfigurationManager.AppSettings["bcClientSecret"];
var request = new RestRequest(Method.POST);
request.RequestFormat = DataFormat.Json;
string json = JsonConvert.SerializeObject(todo);
request.AddHeader("User-Agent", "MyApp (my@email.com)");
request.AddHeader("Content-type", "application/json");
request.AddHeader("charset", "utf - 8");
request.AddHeader("Authorization", userInfo.BaseCampToken);
request.AddParameter("client_id", baseCampClientId);
request.AddParameter("client_secret", baseCampClientSecret);
request.AddParameter("access_token", userInfo.BaseCampToken);
request.AddBody(json);
var result = client.Execute(request);
string jsonResult = result.Content;

回应总是403 Forbidden

我在请求正文中发送的 json 是

JSON

"{\"content\":\"solve this thing\",\"due_at\":\"2014-07-10T00:00:00.0000000\",\"assignee\":{\"id\":\"1111111\",\"type\":\"Person\"}}"

这是请求的图像

呼唤的回应

请帮我解决这个403 forbidden问题

4

1 回答 1

1

well i tried your code with only changing one thing and it worked for me. my changes were:

  1. client.Authenticator = new Auth2AuthorizationRequestHeaderAuthenticator(userInfo.BaseCampToken) for request.AddParameter("access_token", userInfo.BaseCampToken);

also try removing "assignee" from your json data if you have any.

于 2014-07-19T19:20:22.107 回答