0
votes

I'm using logic apps to call the Connectwise Document API to attach images, pdfs, emails, etc. to tickets. I can call the endpoint directly via postman and everything works fine, and when I try to replicate the request in Logic Apps, it looks like everything is working fine, but when I get the file at the end (attached to my Connectwise ticket), the image, excel sheet, whatever is corrupted. Text attachments work somehow.

The logic app listens to a mailbox, so I've been extracting the attachments and uploading to BLOB storage and sending the file content of that (Obtained via GET BLOB) in my request. When the files are in azure storage, they are fine (I can download them and send them via postman and they show up fine).

Any idea what might be going on here? Details below (sorry I'm not sure how the images work on stack overflow):

Blob Cycle

HttpRequest

And here's the code representation:

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Dis-data; name="recordId"

@{body('Extract_Ticket_Id')['id']}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Dis-data; name="recordType"

Ticket
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Dis-data; name="title"

@{items('For_each')['Name']}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Dis-data; name="file"; filename="@{items('For_each')['Name']}"

@{body('Get_Attachment')}
------WebKitFormBoundary7MA4YWxkTrZu0gW--

Is Get Blob the best way to get my Blobs from storage? I haven't been able to find any other methods and it feels like this should work.

Thanks in advance for any help! Let me know if you need more details!

~Josh

PS: There's a similar question asked here, but I don't know that I have the same issue since I don't have access to the server: Azure logic app http post multipart/form-data file upload

Example generated request:

"headers":{"Authorization":"sanitized","Content-Type":"multipart/form-data; boundary=--------------------------784847071658899446745122"}

"body":"----------------------------784847071658899446745122\nContent-Disposition: form-data; name=\"file\"; filename=\"Email to Ticket Review.xlsx\"\nContent-Type: image/png\n\nPK\u0003\u0004\u0014\u0000\u0006\u0000\b\u0000\u0000\u0000!\u0000��`��\u0001\u0000\u0000:\u0007\u0000\u0000\u0013\u0000\b\u0002[Content_Types].xml 

(the blob content continues for a while)

\n----------------------------784847071658899446745122\nContent-Disposition: form-data; name=\"recordType\"\n\nTicket\n----------------------------784847071658899446745122\nContent-Disposition: form-data; name=\"title\"\n\nEmail to Ticket Review.xlsx\n----------------------------784847071658899446745122\nContent-Disposition: form-data; name=\"recordId\"\n\n1257561\n----------------------------784847071658899446745122--"}
1
How are the http headers set when you run the logic app? You should be able to see the body and headers right before you post to your end and can verify if it looks good there or not.Souciance Eqdam Rashti
I've updated with an example request generated by Logic Apps, it looks like the headers at least are ok. The "recordId", "recordType" and "Title" fields are all ok and are being generated correctly at the ConnectWise end. That leaves the actual blob content and that's obviously difficult to compare =/Josh Bowdish
I have not used get blob in a logic app before, but perhaps the action base64 encodes the data and you need to decode it?Souciance Eqdam Rashti

1 Answers

0
votes

You will need to switch to code view to apply this function manually, final HTTP body should look like the following:

“body”: “@{base64ToBinary(items(‘For_each’)?[‘ContentBytes’])}”,