Post Gmail attachment to a web API created in C#

140 views
Skip to first unread message

Paul Nerie

unread,
Feb 15, 2022, 2:51:28 PM2/15/22
to Google Apps Script Community
I'm trying to create a Gmail add-on that will post an email to a web API created in C#.

I can now post an email without attachments. My problem is sending the attachment over.

The API has a parameter byte[] paramName, and thought that the method getBytes() will return the byte array of the object.

But this does not work, a snippet of the object returned by getBytes() has negative values (not sure if that is correct):

Logging output too large. Truncating output. [-119.0, 80.0, 78.0, 71.0, 13.0, 10.0, 26.0, 10.0, 0.0, 0.0, 0.0, 13.0, 73.0, 72.0, 68.0, 82.0, 0.0, 0.0, 0.0, -56.0, 0.0, 0.0, 0.0, -6.0, 8.0, 6.0, 0.0, 0.0, 0.0, -28.0, -22.0, 8.0, 56.0, 0.0, 0.0, 0.0, 9.0, 112.0, 72.0, 89.0, 115.0, 0.0, 0.0, 18.0, 116.0, 0.0, 0.0, 18.0, 116.0, 1.0, -34.0, 102.0, 31.0, 120.0, 0.0, 0.0, 0.0, 7.0, 116.0, 73.0, 77.0, 69.0, 7.0, -26.0, 2.0, 14.0, 6.0, 21.0, 28.0, -79.0, -17.0,

The API is POST method that accepts JSON formatted body as parameter. As mentioned, calls without attachments work.

Has anyone done this before? Can anyone assist with this?

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages