Posting files to iHub Cloud
Webhooks in iHub let you trigger file uploads using multipart/form-data
. The file data itself is included in a variable, typically named file
. You can also include additional text data as needed. This way, iHub can process both the file and any extra information you send along to any remote api or Jira.
How to set it up
Create an integration
Click on Triggers
Select Incoming Webhook
This will give you a token to use to post to iHub. Now you will have a new integration that can receive data. The incoming data will be put into a variable called input
and divided into fields
and files
variables inside the input.
{
"input": {
"fields": {
"issueKey": "D1-3",
"myFormField": "more data"
},
"files": [
{
"filename": "snip.txt",
"mimeType": "text/plain",
"encoding": "7bit",
"key": "43caf17b-786f-4a68-bfb0-df0123c2d007"
}
]
}
}
Next step is to use the data
Click New Action
In the URL put in the remote end-point that the file will be sent to. You may use the
{{input.fields.<your var>>}}
to access any additional field.Select the supported Method for the remote api.
On the body part, select
form-data
radio button.In the body enter
{ "file":"{{input.files}}" }
The {{input.files}}
is a special command to package the files as multipart data.
Now when ever you post to iHub with the token it will parse the files and post it to the next api.
In addition you may send any other form-data parameter by adding it to the body
{
"file":"{{input.files}}",
"text":"{{input.fields.myFormField}}"
}
Posting the incoming file to Jira Issue
In this example we post a file called myFile.txt together with a field called issueKey.
example curl would be
curl -X POST https://ihubdev.rixter.net/dev/incoming/webhook?token=YOUR_TOKEN -F "issueKey=your_issue_key" -F "file=@myFile.txt"
Sending the above POST will give iHub the following scope
Click New Action
Select method
POST
Set URL to
{{baseUrl}}/rest/api/3/issue/{{input.fields.issueKey}}/attachments
On the body part, select
form-data
radio button.In the body enter
Now when ever you post to iHub with the token it will parse the files and post it to Jira and attach it to the issue.
Â
Â
Â