I am struggling with the webmethod.IO workflow to send a CSV file to the Smartsheet attachment. It looks like I am missing something. Can anyone please share the Postman collection?
File: C:\temp\master.csv
HTTP POST: https://api.smartsheet.com/2.0/sheets/{SheetID}/attachments
I tried to set the filename and path. Looks like it requires passing the memory stream and size of the file. My CSV file is only 20 KB.
I've never used webmethods.io, but based on their documentation it looks like the only add attachment operation it supports is Attach File to Row.
The operation to attach a file to a row with the Smartsheet API is:
POST https://api.smartsheet.com/2.0/sheets/sheetId/rows/rowId/attachmentsIn this endpoint, replace
sheetIdwith the ID of the sheet and replacerowIdwith the ID of the row. You can determine both values by using the Smartsheet web app.Propertiesfrom theFilemenu along the top of the screen.Propertiesfrom the popup menu.You'll need to set 4 HTTPS headers for this request:
In these headers, you'll need to replace
YOUR_ACCESS_TOKEN HEREwith the value of your API Access Token and replaceNUMBER_OF_CHARACTERS_IN_YOUR_CSV_FILE_HEREwith a numeric value that represents the number of characters (including all commas) in your csv file.For example, here are the headers that I set when testing the operation in Postman:
The contents of my csv file is simply:
this,is,a,test-- which is 14 characters in length (the value of theContent-Lengthheader in my request).Finally, you'll set the body of the request to the contents of your file (in binary format). When I tested this operation in Postman, I was able to select
binaryformat for the body, and then just choose my file via the UI -- so I didn't have to manually convert my file contents to binary format -- Postman did it for me.In Postman, I pressed the
Select filebutton shown in the screenshot above and then chose the file from my machine that I wanted to upload:I imagine that webmethods.io is the same -- i.e., I'm guessing you can just choose/upload the file via the webmethods.io user interface.
That all said, if the webmethods.io documentation is out of date and it does actually support the Attach File to Sheet operation, then everything would be the same as I've described above, except that there would be no
rowIdat the end of the endpoint:https://api.smartsheet.com/2.0/sheets/{sheetId}/attachments