2012-03-19 7 views
2

저는 trello api에 새로운데, node.js를 사용하고 있습니다. GET 요청은 node.js와 잘 작동하지만 특정 보드의 저장소 목록에 POST 요청을 보내면 권한이없는 오류가 발생합니다. 내 코드는 다음과 같습니다.node-trello 모듈을 사용하여 게시물 요청을 보냅니다.

t.post('/1/boards/board_id/lists?scope=read,write',{text:'test'}, function(err,data){ 
     if(err){  
      console.log("err "+err); 
      return res.send(err); 
     } 
     else{ 
     console.log(data); 
     return res.send(data); 
     } 
    }); 

누군가 내가 잘못하고있는 부분을 알려주십시오.

답변

3

나는 잘못 될 수있는 몇 가지를 봅니다.

먼저, scope = read 인 api 토큰을 요청 했습니까? 당신이 https://github.com/lmatteis/node-trello의 지시에 따라하는 경우

https://trello.com/1/connect?key=YOUR_PUBLIC_KEY&name=MyApp&response_type=token&scope=read,write

읽기의 토큰 수를 얻을 (실제 공개 키로 YOUR_PUBLIC_KEY 교체) 작성 할 필요가있다.

두 번째로 게시 URL의 board_id에 해당 보드 ID를 대신 사용 하시겠습니까?

마지막으로 'text'는 'name'이어야합니다. 당신은 당신이 발급 한 토큰의 속성을 확인하려는 경우

var Trello = require("node-trello"); 

var t = new Trello("[YOUR API KEY]", "[YOUR TOKEN THAT YOU GOT BY HITTING trello.com?connect URL ABOVE]"); 

t.get("/1/boards/[THE ID OF THE BOARD]/lists", function(err, data) { 
    if(err) throw err; 
console.log(data); 
}); 

t.post('/1/boards/[THE ID OF THE BOARD]/lists', {name:'test'}, function(err,data){ 
    if (err) { 
     console.log("err " + err); 
    } else { 
    console.log(data); 
    } 
    } 
); 

, 당신이 할 수있는 API를 통해도 (:

그래서 모두 함께 넣어, 여기에 작동해야 무언가이다 https://trello.com/docs/api/token/index.html 참조).

관련 문제