How to launch a request with a FILE using WebHooks

Configure the process

To send a file to a process you need to, do the following:

  1. Enable sub-process mode in the process and set Access level to Public.

  1. Create a file data (such as REQUEST_FILE) and select IN or INOUT as sub-process parameters.

Create%20file%20data

  1. Create an Incoming webhook type application.

webhook

Create a request with a file as parameter

With webhooks, you need to use the createRequest method. There are three ways to send a file:

  • Send a file URL

  • Send a base64 file

  • Send an uploaded file

Send a file URL

The file you want to upload needs to be accessible by WorkflowGen. You can set a physical path in the URL that will be accessible by WorkflowGen (prefixed by file:///), or use another URL.

Local file

{
"operation": "createRequest",
    "args": {
        "input": {
            "processName": "SIMPLE_REQUEST_FILE",
            "processVersion": 1,
            "parameters": [{
                "name": "REQUEST_FILE", 
                "fileValue": {
                    "name": "test.txt",
                    "contentType": "text/plain",
                    "size": 616,
                    "url": "file:///C:/Hooks/test.txt"
                }
            }]
        }
    }
}

To authorize WorkflowGen to access your file, go to the Configuration Panel Integration tab. In the Webhooks section, enter your folder path in the Input file allowed folders (comma separated values) field.

setfolderhooks

Public file

{
"operation": "createRequest",
    "args": {
        "input": {
        "processName": "SIMPLE_REQUEST_FILE",
        "processVersion": 1,
        "parameters": [{
            "name": "REQUEST_FILE", 
            "fileValue": {
                "name": "test.txt",
                "contentType": "text/plain",
                "size": 4120858,
                "url": "http://download.workflowgen.com/product/latest/update.zip"
            }
        }]
        }
    }
}

Use file content parameter

{
"operation": "createRequest",
    "args": {
        "input": {
            "processName": "SIMPLE_REQUEST_FILE",
            "processVersion": 1,
            "parameters": [{
                "name": "REQUEST_FILE", 
                "fileValue": {
                    "name": "test.txt",
                    "contentType": "text/plain",
                    "size": 12,
                    "content":"SG9va3MgRmlsZQ=="
                }
            }]
        }
    }
}

To authorize WorkflowGen to rebuild the file, go to the Configuration Panel Integration tab. In the Webhooks section, set the size in the Maximum input file content size (kB) field.

setsizehooks

Use an uploaded file

curl -X POST \
  http://localhost/wfgen/hooks/HOOKSTOKEN \
  -H 'content-type: multipart/form-data' \
  -F 'payload={"operation": "createRequest", "args": { "input": {"processName": "SIMPLE_REQUEST_FILE", "processVersion": 1, "parameters": [ { "name": "REQUEST_FILE", "fileValue": {"uploadMap":"z_file1" }}] } } }' \
  -F 'z_file1=@C:\Hooks\test.txt'

Input.parameters[X].fileValue should contain an uploadMap whose value is the (\"fileValue\": {\"uploadMap\":\"z_file1\" }) key of the file to be uploaded.

You can add more than one file.

Test

You can use the postman project to test.