How would I compose a json key, value array from a list of files to pass to the Postmark API to be attachments in an email

I have a process where I am sending an email using the postmark api and in order to pass the attachments which are stored in a table, they need to be passed as an array in json format.

Documentation is here: Email API | Postmark Developer Documentation

Example from docs is here:

 "Attachments": [
      {
        "Name": "readme.txt",
        "Content": "dGVzdCBjb250ZW50",
        "ContentType": "text/plain"
      },

The attachments or files are stored as a list and I need to create some type of workflow step where each of the files is read and used to create the key value pair that is passed to the api.

Any help in how to achieve this would be greatly appreciated,

Many thanks

Frank

Usethe list of files :format as text and put in the values you want for each file

1 Like

+1

I’m assuming you have a data type that stores the reference for each file?

If so, use Do a Search which always returns a list of things, and then using :format as text with a comma delimiter is a great way to build up a JSON list, especially as it handles the trailing comma issue elegantly.

Thank you @code-escapee and @will_ericksson. I have used both your suggestions and getting closer to a solution. I have managed to get the json to form correctly however the actual send email is failing so I am edging closer to solution but not there yet - I hope to be by tomorrow. Many thanks for your help

1 Like

Is that “Content” value in the example supposed to be the read result?

Thank you again
this is resolved and working

This topic was automatically closed after 70 days. New replies are no longer allowed.