File Attachment to Row

11/25/20
Answered - Pending Review

Hi Team ,

I am trying to attach file to smartsheet row with the following details,

https://api.smartsheet.com/2.0/sheets/{Sheet ID }/rows/{ Row ID }/attachments

Header :

Authorization:Bearer {ACCESS TOKEN}

Content-Type:image/jpeg

Content-Disposition:attachment; filename="C:\1.jpeg"

ContentLength:64

Response I am getting below is :

{

    "message": "SUCCESS",

    "resultCode": 0,

    "result": {

        "id": 6967695279187844,

        "name": "C__1.jpeg",

        "attachmentType": "FILE",

        "mimeType": "image/jpeg",

        "sizeInKb": 1,

        "parentType": "ROW",

        "parentId": 1936240127567748,

        "createdAt": "2020-11-25T07:57:55Z",

        "createdBy": {

            "name": "Evaluation",

            "email": "[email protected]"

        }

    },

    "version": 18

}

But the file which is attached is corrupted and throws following error ,

Same error happens with docx files as well, please help us in this regard.


Answers

  • Tony LucasTony Lucas Employee

    Hi,

    Can you check that you are setting the content length header correctly (it looks to have a missing hyphen it), and that you are setting the length correctly. I'd be surprised if it's only 64 bytes in size (although not impossible)

    Also ensure you are setting the mime type correctly for the word doc as it's different than for a JPEG.

    I can't say for definite that is the source of your problem but would be good to rule them out first.

  • Hi ,

    Sorry , i was giving the content length in kb , i changed and gave it in bytes even then the same error occurs.

    Also for the word document i have given the content type as application/msword. Sadly that didnt work as well.

    Please find below the header details provided for attaching word document.

    Authorization:Bearer {ACCESS TOKEN}

    Content-Type:application/msword

    Content-Disposition:attachment; filename="C:\1.docx"

    ContentLength:68000

Sign In or Register to comment.