Unable to Attach File to Row

AbhijitAbhijit
edited 04/21/21 in API & Developers
04/20/21 Edited 04/21/21
Answered - Pending Review
curl https://api.smartsheet.com/2.0/sheets/{sheetId}/rows/{rowId}/attachments \
-H "Authorization: Bearer xxxx" \
-H "Content-Type: application/msword" \
-H 'Content-Disposition: attachment; filename="ProgressReport.docx"' \
-H "Content-Length: FILE_SIZE" \
-X POST \
--data-binary @ProgressReport.docx

Using Above API to attach a file but getting below errors -

1.If I don't Provide --data-binary @ProgressReport.docx then Getting error - "errorCode": 1011,"message": "A required header was missing or invalid: Content-Length"

2.After providing above tag get TimeOut error.

This is happening always. Do we need to provide "--data-binary @ProgressReport.docx" or providing Path in fileName will suffice ?

--data-binary Shoul contain all content of binary file eg --data-binary @"<<binary content>> ?"

Answers

  • Hi @Abhijit

    First of all, please note that I removed out your Bearer token from this public Community post. Since it was visible for a period of time, I would recommend revoking your current token and generating a new one in order to keep your data secure.

    In regards to Content-Length, this must be set to the size of the file, in bytes.

    Ex: Content-Length: 5463

    You will then also need to provide the binary content for file. The new updated API documentation has details on what's required here: Post an Attachment.

    Keep in mind the attachment size limits, which can be seen here.

    Let me know if this has helped!

    Cheers,

    Genevieve

  • @Genevieve P  - Thanks for your reply.

    The Bearer token was from smartsheet documentation and was not proper/correct token :)

    After providing the  binary content even for 1kb file I'm getting TimeOut error.

  • Hi @Abhijit

    I'm not sure why you're receiving a timeout error. I would recommend reaching out to Smartsheet Support so you can provide them with your exact request, the file, and a screen capture of the error message. They can troubleshoot with you in a private channel.

    Thanks,

    Genevieve

Sign In or Register to comment.