To start off I am having the same problem as the op in this thread I am trying to build a slackbot using botkit by howdy and having difficulty uploading files using the file.upload api.
bot.api.files.upload({
token: process.env.token,
content: fs.createReadStream("example.txt"),
filetype: "js",
channels: message.channel
},function(err,response) {
if(err) {
console.log("failed to add file",err)
bot.reply(message, 'sorry there was an error: '+err)
}
});
This code gives me the invalid_array_arg error and I tried using the solution in the thread I linked and my code is this
request.post({
url: 'https://slack.com/api/files.upload',
formData: {
token: process.env.token,
file: fs.createReadStream('example.txt'),
channels: message.channel,
},
}, function(err,response) {
console.log(JSON.parse(response.body));
});
But this gives me this error
Running skill code for uploadFiles...
/Users/username/bottie/node_modules/request/request.js:336
if (value.hasOwnProperty('value') && value.hasOwnProperty('options')) {
^
TypeError: Cannot read property 'hasOwnProperty' of undefined
I have 'requests' and 'fs' as required var already so I don't think that's what making the errors happen, but thanks in advance for any help received
via John Smith
No comments:
Post a Comment