When an AS2 file is imported to a third-party AS2 server, integrator.io allows you to update the file name format using the File name setting.
Use handlebar expressions to include a variable (such as timestamp, unique ID, and other AS2 metadata) in your file name. This will be helpful when there are multiple files that are being imported and ensures each file name is unique. In the screenshot above, the timestamp handlebar in UNIX code, Item_{{timestamp 'x'}}, is used to generate the file name, Item_1687801277413.
The value from the File name setting is passed in the AS2 message's Subject header, as shown below:
You need to update the configuration in the third-party AS2 server to read the AS2 file name in the same format as saved in integrator.io.
Note: This information isn't parsed automatically in the third-party AS2 server. The configuration method to fetch the file name differs for each third-party AS2 application server.
Send the file name in a Content-Disposition header
integrator.io sends the File name value in the AS2 message's Subject header, as File <name> sent from <your AS2 identifier> to <your partner's AS2 identifier>. The name isn't written on the document itself. Many AS2 servers read the file name from the document's Content-Disposition header instead of from Subject. The Content-Disposition line in the screenshot above belongs to the signed message, not to the document. If your partner reports that no file name came with the document (for example, their server logs No original filename specified, writing to unique name and saves each file under a generated name), add that header to the AS2 import.
Open the AS2 import. In How would you like the records imported?, after you select the File type, go to Configure HTTP headers. In the empty row, enter Content-Disposition as the name and attachment; filename="<the same expression as File name>" as the value, for example attachment; filename="810_{{record.invoiceNumber}}.edi". Leave File name as it is. integrator.io adds the header to the document before it signs and encrypts the message, so your partner reads it after decrypting. This works only when Compress files, under Advanced, isn't checked.
- Write the header name exactly as
Content-Disposition, with a capital C and a capital D. - Use a name your partner's system accepts. A bare
{{timestamp}}contains colons, which some AS2 servers refuse; give it a format instead, such as{{timestamp "YYYYMMDD_HHmmss"}}.
To confirm the header is sent, turn on the debugger for the AS2 connection (see Debug a connection) and check the SIGNED-DATA entry in the log: the Content-Disposition line appears above the document. Then ask your partner to confirm the file name their server saved. If their server still stores a generated name with the header in place, your partner needs to change a setting on their AS2 server.