# How to launch a request with a FILE using WebHooks

**URL:** <https://discuss.workflowgen.com/t/how-to-launch-a-request-with-a-file-using-webhooks/1287>\
**Category:** Integration\
**Created:** [January 29, 2019, 3:13pm UTC](https://discuss.workflowgen.com/t/how-to-launch-a-request-with-a-file-using-webhooks/1287 "2019-01-29T15:13:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![qpomarel](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/qpomarel/32/262_2.png) [@qpomarel](https://discuss.workflowgen.com/u/qpomarel)\
**Post date:** [January 29, 2019, 3:13pm UTC](https://discuss.workflowgen.com/t/how-to-launch-a-request-with-a-file-using-webhooks/1287/1 "2019-01-29T15:13:54Z")

</div>

## 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`.

 ![Enable%20subprocess](https://canada1.discourse-cdn.com/flex030/uploads/workflowgen/original/1X/d4023f5d43826f1e3f2a117e2acdde0e90b75e94.gif)

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

![Create%20file%20data](https://canada1.discourse-cdn.com/flex030/uploads/workflowgen/original/1X/3f9f86557029a65a61bff68c19b20ea2a586a72e.gif)

1. Create an **Incoming webhook** type application.

![webhook](https://canada1.discourse-cdn.com/flex030/uploads/workflowgen/original/1X/431df6b89b0605c31cf0d07c1722637d05a2156f.gif)

## 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

```json
{
"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](https://canada1.discourse-cdn.com/flex030/uploads/workflowgen/original/1X/b20db69d00044281e0a976d0293156467592712b.gif)

#### Public file

```json
{
"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

```json
{
"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](https://canada1.discourse-cdn.com/flex030/uploads/workflowgen/original/1X/3128ec5a10cd785d97b01441f241d78b8d85eb84.gif)

### Use an uploaded file

```auto
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](https://download.workflowgen.com/forum/How-To-Send-A-File-With-Webhooks/WebHooks-File-Postman.zip) to test.
