Upload file/attachment
Hi. I am working with some automation tools that read an outlook email, parse the email, and upload the information to Smartsheet via API. I have completed all those steps and it has been successful. However, I am struggling to upload the attachment, which is in PDF format. I saw the documentation on this, but I keep getting an error because the PDF is stored locally and I do not have the 'URL'. Basically, I would like to know how to upload a pdf attachment stored locally and would like to know the "JSON Query" for that attachment. Thank you so much. I have been struggling for far too long on this portion and threw so much at it.
Answers
-
try the below setup in the request body
{
"$content-type": "application/pdf",
"$content": "base64string"
}
-
Hi,
When I tried that, this is the error I got @Leibel S .
{
"errorCode": 1008,
"message": "Unable to parse request. The following error occurred: Unknown attribute \"$content-type\" found at line 3, column 20",
"refId": "jz8dfv"
}
These are a few strings I did.
- I tried this -- with the URL "https://api.smartsheet.com/2.0/sheets/{sheetId}/attachments",
attachment Query:
{
- "attachmentSubType": "DOCUMENT",
- "attachmentType": "File",
- "description": "string",
- "name": "string",
- "url": "string" -- (Locally stored file path)
}
This doesn't work too.
THis is the documentation I followed. I hope I can get this fixed. =(
"https://smartsheet.redoc.ly/tag/attachments#operation/attachments-attachToSheet"
-
How to send a file from a client to a smartsheet using api?
-
const { Readable } = require('stream'); var fs = require("fs") const apload = (req, res) => { const smartsheet = req.smartsheetClient console.log(req.file) // Создаем поток чтения из Buffer const bufferStream = new Readable(); bufferStream.push(req.file.buffer); bufferStream.push(null); // Обработка загруженного файла const options = { sheetId: 1234567890123456, fileSize: req.file.size, fileName: encodeURIComponent(req.file.originalname), // fileStream: fs.createReadStream(req.file) fileStream: bufferStream }; // Attach file to sheet smartsheet.sheets.addFileAttachment(options) .then(function (attachment) { console.log(attachment); res.send('файл загружен') }) .catch(function (error) { console.log(error); }); } exports.apload = apload
router.js:
const upload = multer({ storage: storage }); const { apload } = require('./routes/smartsheet/upload'); const router = express.Router(); router.post('/upload', upload.single('file'), apload)
-
@Bortyk - Can you please share the Postman collection? I want to test. I am planning to integrate to the WebMethods.
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 439 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 67 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives