# How to handle request payloads larger than 5MB

Both [**REST**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/rest) and [**HTTP**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/http) triggers have a payload limit of 5MB. If this limit is reached, the Platform returns the HTTP status "413" with the following message:

```json
{
    "message": "Request size limit exceeded"
}
```

Below you can find out more about an alternative method for handling requests that exceed the payload limit.

## **Step-by-step guide for handling requests larger than 5MB**

{% stepper %}
{% step %}

### **Use the HTTP File Trigger**

You can use the [**HTTP File Trigger**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/http-file) to process payloads larger than 5MB by sending the data as a file.

Specify the appropriate content type for your file under **Body Upload** and **Response Content-Types**. In this example, the value is `application/json`, but it can also be other formats, such as `application/pdf` or `application/jpeg`.

<figure><img src="https://content.gitbook.com/content/boT4qPJIk6PZotrxlJWL/blobs/dp7YurjVgJvGG5pVUOF2/HTTP%20File%20Trigger.png" alt=""><figcaption></figcaption></figure>

After receiving the payload with the [**HTTP File Trigger**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/http-file), you can access the **Monitor** page to see the [**Execution Details**](https://app.gitbook.com/s/jvO5S91EQURCEhbZOuuZ/development-cycle/dashboards/completed-executions). Note that the payload is received as a file and not in the body key. In this context, the body key is empty.

<figure><img src="https://content.gitbook.com/content/boT4qPJIk6PZotrxlJWL/blobs/EbfZQGC2RmJjQvQT7Bc2/image1.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/boT4qPJIk6PZotrxlJWL/blobs/q03gAcN2vq4KraYn754o/image3.png" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### **Save the input data in the Session Management connector**

Special handling is required to access the uploaded file. A common approach is to store the request’s input data in a [**Session Management**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/connectors/structured-data/session-management) connector, preserving details such as `Headers` and `QueryAndPath`.

<figure><img src="https://content.gitbook.com/content/boT4qPJIk6PZotrxlJWL/blobs/06PIPCKTDlnjUJAQJaIl/Session%20Management%20connector.png" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### **Convert the string into JSON**

Use the [**File Reader**](https://app.gitbook.com/s/SKBJ6ZiEWBU93x170HH4/connectors/files/file-reader) connector to read the file and convert it into a JSON string. Then, apply the Double Braces [`TOJSON` function](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/double-braces/double-braces-functions/json-functions) to transform it into a JSON object.

In this example, the conversion takes place in the [**JSON Generator**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/connectors/tools/json-generator) connector, named "TOJSON data", as illustrated in the image below.

<figure><img src="https://content.gitbook.com/content/boT4qPJIk6PZotrxlJWL/blobs/7jBJtegYb3iHhXx1Pr9R/JSON%20Generator%20(Mock).png" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### **Configure the response of the pipeline**

Once you have obtained the desired payload, you need to prepare the pipeline's response. You can return either a `.json` file or a JSON object.

To generate a file, use the [**File Writer**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/connectors/files/file-writer) connector:

<figure><img src="https://content.gitbook.com/content/boT4qPJIk6PZotrxlJWL/blobs/FWRj03iOpw2pCZKbjGuS/File%20Writer.png" alt=""><figcaption></figcaption></figure>

Alternatively, you can use a [**JSON Generator**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/connectors/tools/json-generator) connector to structure and provide the final response, as shown in the following example:

<figure><img src="https://content.gitbook.com/content/boT4qPJIk6PZotrxlJWL/blobs/RDC4MzXh6e1T3zkQLVii/JSON%20Generator%20(Mock)%20-%20Response.png" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}
