I am building a Powershell module. Yes I know there is the C# SDK but I do not want that as a dependency for this Module.
I am struggling with this API Call:
Attach File or URL to Sheet
This is my code:
$BaseURI = "https://api.smartsheet.com/2.0"
$Id = {smartsheet id}
$filename = "MyDoc.docx"
$mimetype = "application/msword"
$Uri = "{0}/sheets/{1}/attachments" -f $baseUri, $id
$AuthCode = "{my auth code}"
$token = ConvertTo-SecureString -String $AuthCode -AsPlainText -Force
$response = Invoke-RestMethod - Method POST -Uri $Uri -Infile $filename -ContentType $mimetype -Authentication:Bearer -Token $Token
The response I get back from the API is:
{ "errorCode" : 1008, "message" : "Unable to parse request. The following error occurred: Request body must be either a JSON object or JSON array.", "refId" : "12y60zzovzndm" }
For sending a file this should work.
If I post to this API Call in Postman it works.