Open ghost opened 7 years ago
Looks like your Trello API key and secret are not defined.
No, I must be doing something wrong in the api.json, because within the same code I can create board or list with the initial API calls but the recent added by me for getListCards is giving back that message. I can provide the full code if this may help.
Indeed I get the same error using the function which is coming standard in your code. Just before I use the functions to create board or create lists and everything works great.
trello.getLists({idBoard: '580698b3fa7cd8fe326e9441'}).then(function(lists) {
// return console.log("have lists: " + (lists.map(function(l) {return l.name;}).join(', ')));
console.log(lists);
});
Same issue for me. Create a board (and it does) and try a getBoard in the creates callback and gets the 401 error. Obviously, the key and token would be the same for both calls. Full code :
var trello = require('trello-client')(process.env.TRELLO_KEY, process.env.TRELLO_TOKEN);
trello.createBoard({name:'Bugs'}).then(function(board) {
console.dir(board);
trello.getBoard({
idBoard: board.id,
lists: 'all',
cards: 'all',
checklists: 'all'
}).then(function(board) { console.dir(board); })
})
Output is:
{ id: '58c3b31ccb66706fce29bb4e',
name: 'Bugs',
desc: '',
descData: null,
closed: false,
idOrganization: null,
pinned: false,
url: 'https://trello.com/b/FGQf2xon/bugs2',
shortUrl: 'https://trello.com/b/FGQf2xon',
prefs:
{ permissionLevel: 'private',
voting: 'disabled',
comments: 'members',
invitations: 'members',
selfJoin: true,
cardCovers: true,
cardAging: 'regular',
calendarFeedEnabled: false,
background: 'blue',
backgroundImage: null,
backgroundImageScaled: null,
backgroundTile: false,
backgroundBrightness: 'dark',
backgroundColor: '#0079BF',
canBePublic: true,
canBeOrg: true,
canBePrivate: true,
canInvite: true },
labelNames:
{ green: '',
yellow: '',
orange: '',
red: '',
purple: '',
blue: '',
sky: '',
lime: '',
pink: '',
black: '' } }
Unhandled rejection StatusCodeError: 401 - invalid key
at new StatusCodeError (/home/ubuntu/workspace/trelloclient/node_modules/trello-client/node_modules/request-promise/lib/errors.js:26:15)
at Request.RP$callback [as _callback] (/home/ubuntu/workspace/trelloclient/node_modules/trello-client/node_modules/request-promise/lib/rp.js:68:32)
at Request.self.callback (/home/ubuntu/workspace/trelloclient/node_modules/trello-client/node_modules/request-promise/node_modules/request/request.js:188:22)
at emitTwo (events.js:87:13)
at Request.emit (events.js:172:7)
at Request.<anonymous> (/home/ubuntu/workspace/trelloclient/node_modules/trello-client/node_modules/request-promise/node_modules/request/request.js:1171:10)
at emitOne (events.js:77:13)
at Request.emit (events.js:169:7)
at IncomingMessage.<anonymous> (/home/ubuntu/workspace/trelloclient/node_modules/trello-client/node_modules/request-promise/node_modules/request/request.js:1091:12)
at IncomingMessage.g (events.js:260:16)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:923:12)
at nextTickCallbackWith2Args (node.js:458:9)
at process._tickCallback (node.js:372:17)
Kim,
Check out https://github.com/liquidlabs-co/trello-client
They are continuing maintenance of the project.
On 11 Mar 2017, at 0:32, Kim McKinley notifications@github.com wrote:
Same issue for me. Create a board (and it does) and try a getBoard in the creates callback and gets the 401 error. Obviously, the key and token would be the same for both calls. Full code :
var trello = require('trello-client')(process.env.TRELLO_KEY, process.env.TRELLO_TOKEN);
trello.createBoard({name:'Bugs'}).then(function(board) { console.dir(board); trello.getBoard({ idBoard: board.id, lists: 'all', cards: 'all', checklists: 'all' }).then(function(board) { console.dir(board); }) }) Output is:
{ id: '58c3b31ccb66706fce29bb4e', name: 'Bugs', desc: '', descData: null, closed: false, idOrganization: null, pinned: false, url: 'https://trello.com/b/FGQf2xon/bugs2', shortUrl: 'https://trello.com/b/FGQf2xon', prefs: { permissionLevel: 'private', voting: 'disabled', comments: 'members', invitations: 'members', selfJoin: true, cardCovers: true, cardAging: 'regular', calendarFeedEnabled: false, background: 'blue', backgroundImage: null, backgroundImageScaled: null, backgroundTile: false, backgroundBrightness: 'dark', backgroundColor: '#0079BF', canBePublic: true, canBeOrg: true, canBePrivate: true, canInvite: true }, labelNames: { green: '', yellow: '', orange: '', red: '', purple: '', blue: '', sky: '', lime: '', pink: '', black: '' } } Unhandled rejection StatusCodeError: 401 - invalid key at new StatusCodeError (/home/ubuntu/workspace/trelloclient/node_modules/trello-client/node_modules/request-promise/lib/errors.js:26:15) at Request.RP$callback [as _callback] (/home/ubuntu/workspace/trelloclient/node_modules/trello-client/node_modules/request-promise/lib/rp.js:68:32) at Request.self.callback (/home/ubuntu/workspace/trelloclient/node_modules/trello-client/node_modules/request-promise/node_modules/request/request.js:188:22) at emitTwo (events.js:87:13) at Request.emit (events.js:172:7) at Request.
(/home/ubuntu/workspace/trelloclient/node_modules/trello-client/node_modules/request-promise/node_modules/request/request.js:1171:10) at emitOne (events.js:77:13) at Request.emit (events.js:169:7) at IncomingMessage. (/home/ubuntu/workspace/trelloclient/node_modules/trello-client/node_modules/request-promise/node_modules/request/request.js:1091:12) at IncomingMessage.g (events.js:260:16) at emitNone (events.js:72:20) at IncomingMessage.emit (events.js:166:7) at endReadableNT (_stream_readable.js:923:12) at nextTickCallbackWith2Args (node.js:458:9) at process._tickCallback (node.js:372:17) — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
@arieljake thanks for the quick reply. Will use https://github.com/liquidlabs-co/trello-client.
I am trying to add a new API point in the api.json file for the API GET /1/lists/[idList]/cards I have added the following block to the api.json:
And make the call in the index.js following this schema:
Unfortunately it is not working and I get the following exception: