- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
16-09-21 04:43 PM
I'm looking for some help with uploading attachment to JIRA issue by using POST action in Web API Services with Single or Multiple Files. I tried multiple solutions so far, but with no success. For a single file approach I tried to use various headers like Content-Type equal to application/json, application/pdf, application/x-binary (and binary), application/octet-stream, etc., X-Atlassian-Token: no-check, Content-Disposition: form-data and many many different combinations. All request were made against such endpoint (as per JIRA docu): https://jira.{base-url}.net//rest/api/[Version]/issue/[Issue ID]/attachments (Version = 2). So far I manage to got 2 results that make any sense. In single file case I'm getting status code 415 which means "Unsupported Media Type" and I was sure that I will be able to fix it with proper header name, but no luck so far 😞 (I'm trying to upload binary file loaded to data item/collection). For the multiple files request I'm receiving status 200 but response content is empty, and...the file is not getting uploaded. I also tried to run cmd command with following cURL code and it's working fine:
curl -D- -u {username}:{password} -X POST -H "X-Atlassian-Token: nocheck" -F "file=@{path/to/file}" http://{base-url}/rest/api/2/issue/{issue-key}/attachments
The only problem is the fact that I'm not able to read response content back to Blue Prism, and this is why I would like to have it in Web API Service where I have a lot others actions too. Does anybody have some experience with that?
Some more details:
I'm on BP 6.10.1, I've removed common headers, other activities are working fine, only file upload is not working.
Thank you in advance!
Answered! Go to Answer.
Helpful Answers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
20-09-21 01:39 PM
Thank you for your respond. After many hours of fight I manage to finally made it works directly from Web API Services. Below screenshots from solution:
The most important part of this solution was to use multiple files method (even if you uploading single file at once), then create an input collection where you can import fields from particular action (by clicking 'Import' button) or reproduce them as per the screenshot:
'File' field needs to has binary file loaded. In the 'File Name' I put full path to the same file. 'Field Name' in this case must be equal to 'file' (without quotes ofc) and 'Content-Type' equal to 'application/octet-stream'. Otherwise JIRA will be responding with status code 200, but no file will be attached.
Edit: I forgot to mention that you need also to use Issue KEY, not issue ID as input parameter (e.g. KEY-123, not e.g. 123456). With Issue ID it won't work.
With all of that, solution is working perfectly. What I found strange is the header 'Content-Type' that cannot be passed through 'Headers' in API tool, but needs to be defined in Collection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
17-09-21 01:59 PM
One thing I noticed from the URL you specified is that you have an extra "/" in there. Not sure if that was just a cut-and-paste error, but you'd definitely want to remove that if that's the way the URL is seen in the WebAPI.
Cheers,
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
17-09-21 02:07 PM
You can use a tool like Fiddler to see exactly what's in the request when it's sent from Blue Prism.
Cheers,
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
20-09-21 01:39 PM
Thank you for your respond. After many hours of fight I manage to finally made it works directly from Web API Services. Below screenshots from solution:
The most important part of this solution was to use multiple files method (even if you uploading single file at once), then create an input collection where you can import fields from particular action (by clicking 'Import' button) or reproduce them as per the screenshot:
'File' field needs to has binary file loaded. In the 'File Name' I put full path to the same file. 'Field Name' in this case must be equal to 'file' (without quotes ofc) and 'Content-Type' equal to 'application/octet-stream'. Otherwise JIRA will be responding with status code 200, but no file will be attached.
Edit: I forgot to mention that you need also to use Issue KEY, not issue ID as input parameter (e.g. KEY-123, not e.g. 123456). With Issue ID it won't work.
With all of that, solution is working perfectly. What I found strange is the header 'Content-Type' that cannot be passed through 'Headers' in API tool, but needs to be defined in Collection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
20-09-21 02:06 PM
Glad to hear you got it working. So it seems what was required was a multi-part form definition which is what I believe using the “Multiple Files” option gives you.
Cheers,
Eric
