Hi!
I am receiving an email with or without an attachment to create an issue in Jira, then send a request to Jira to upload the attachment. In Postman it works but in Flow I can not upload the file.
Send postman with file
My Flow
Condition
Testing request
Testing responde
Testing responde
Solved! Go to Solution.
@Anonymous
Use this:
{ "$content-type": "multipart/form-data", "$multipart": [ { "headers": { "Content-Disposition": "form-data; name=\"file\"; filename=XXXXX" }, "body": XXXXX } ] }
The 'body' should be the file content you get when retrieving the file.
Sam
Hey @Anonymous
I found the issue.
In content put this expression:
item()?['ContentBytes']
It will send only the file, you are sending all informations of file, like name, type and etc.
Best Regards,
Gustavo Moraes
Community Super User
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. And give me a kudo to make me more happy!
Gustavo Moraes, o astronauta brasileiro do Flow!
Hi @gamoraes, thanks for your answer
I still have problems, I built it in the following way, but this message comes back:
org.apache.commons.fileupload.FileUploadException: Stream ended unexpectedly
HTTP
Postman
http Sending
http response
@gamoraes wrote:Hey @Anonymous
I found the issue.
In content put this expression:
item()?['ContentBytes']It will send only the file, you are sending all informations of file, like name, type and etc.
Best Regards,
Gustavo Moraes
Community Super User
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. And give me a kudo to make me more happy!
@Anonymous
Use this:
{ "$content-type": "multipart/form-data", "$multipart": [ { "headers": { "Content-Disposition": "form-data; name=\"file\"; filename=XXXXX" }, "body": XXXXX } ] }
The 'body' should be the file content you get when retrieving the file.
Sam
Thx @SamPo for your help
{ "$content-type": "multipart/form-data", "$multipart": [ { "headers": { "Content-Disposition": "form-data; name=\"file\"; filename=@{items('Aplicar_a_cada_uno')?['Name']}" }, "body": { "$content-type": "@{items('Aplicar_a_cada_uno')?['ContentType']}", "$content": @{items('Aplicar_a_cada_uno')?['ContentBytes']} } } ] }
Hi @SamPo I found this code very helpful. But now I need to include a second file. How would I do that?
Hi @Anonymous
Try this:
{ "$content-type": "multipart/form-data", "$multipart": [ { "headers": { "Content-Disposition": "form-data; name=\"file\"; filename=@{items('Aplicar_a_cada_uno')?['Name']}" }, "body": { "$content-type": "@{items('Aplicar_a_cada_uno')?['ContentType']}", "$content": @{items('Aplicar_a_cada_uno')?['ContentBytes']} },
//second { "headers": { "Content-Disposition": "form-data; name=\"file2\"; filename=@{items('Aplicar_a_cada_uno')?['Name']}" }, "body": { "$content-type": "@{items('Aplicar_a_cada_uno')?['ContentType']}", "$content": @{items('Aplicar_a_cada_uno')?['ContentBytes']} } } } ] }
Thanks @Anonymous for the quick response. You are making my Friday great. I entered what I thought was exactly what you sent. Here's a copy. Still it simply says it's invalid. I have tried several variations.
The code is good if I do 1, but the minute I add the second it's invalid.
I did add the missing } on the bottom section. I'm just not sure it likes 2 files.
Use the ContentBytes from file:
Sintaxis:
{ "$content-type": "multipart/form-data", "$multipart": [ { "headers": { "Content-Disposition": "form-data; name=\"file\"; filename=@{items('Aplicar_a_cada_uno')?['Name']}" }, "body": { "$content-type": "@{items('Aplicar_a_cada_uno')?['ContentType']}", "$content": @{items('Aplicar_a_cada_uno')?['ContentBytes']} } } ] }
Yes, this works great for a single file. How about for 2 files?
@Anonymous Honestly, I just use an apply to each to make multiple calls. If I have 2 files then I make 2 seperate API calls and use the 'body' and 'name' variables to set the name and content of the file.
Yea, but my API is a fax and I need it to go with a cover sheet.
@Anonymous In this case I would set up a new flow triggered by HTTP then use Postman to send a request to that flow with 2 files - Use the Postman files feature to attach both files to a single request.
Then from the run log of the flow you can see how the request is received and this should give you an idea of how to setup your call. Essentially this gives you the best way to see how postman actually sends the data which you can then copy.
Hope this helps,
Sam
Thanks @SamPo . That helped me find all the commas and squigly brackets I needed. I truly appreciate it.
New post coming.
@FoDelement In theory this would be the same as any other custom connector. At the end of the day this is just using some specific headers and specific JSON format but it's still a standard JSON that you should be able to build in the custom connector editor. I've never tried it myself but don't see any reason why it shouldn't work.
Thank you! @SamPo I created my own topic because I can't seem to get mine to work. I am trying either a custom connector or the Azure HTTP request.
User | Count |
---|---|
94 | |
40 | |
23 | |
20 | |
16 |
User | Count |
---|---|
130 | |
49 | |
46 | |
30 | |
25 |