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

  1. Create an integration

  2. Click on Triggers

  3. 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

  1. Click New Action

  2. 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.

  3. Select the supported Method for the remote api.

  4. On the body part, select form-data radio button.

  5. 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

  1. Click New Action

  2. Select method POST

  3. Set URL to {{baseUrl}}/rest/api/3/issue/{{input.fields.issueKey}}/attachments

  4. On the body part, select form-data radio button.

  5. 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.

 

 

Â