Use Variable in Multipart Form-Data Attachment

In a POST, I need to pass a pdf file and a JSON file to tell the application some details about the pdf file. One of the properties is an environment variable “ParticipantID” that I receive in a previous call:

  "executionType": "E-Sign",
  "name": "Retail Installment Contract2",
  "order": 1,
  "participants": [
      "participantUid": "{{ParticipantID}}",
      "required": true

I want to just use the “{{ParticipantID}}” notation in the attachment so that I don’t have to update this file every time I run my collection but this doesn’t seem to work.

I’m following this enhancement request which would probably fix this:

I’ve also looked on stackoverflow and there seem to be some pretty complicated ways (at least for me) where instead of actually attaching a file in Postman, I could submit a string of data and use a variable there.

I’m certainly doing several things wrong in the screenshot above, but the variable doesn’t seem to be recognized and I think there are other things I need to do for this JSON object to be compatible with the multipart format.

If I can’t use the variable notation in the attachment, could I dynamically set the value in the attachment if it’s in my working directory? Or could I convert my attachment to a text string and use a variable there?

Knowing that there’s an enhancement request for this, wondering if anyone has suggestions on workarounds in the meantime.

Thank you!

It turns out that Postman has very simple support for this, but the option I needed to make this work was just in a hidden column in the multipart form-data page.

What worked for me:

  1. Expose the “Content Type” Column in form-data and set to application/json

  2. Change the “file” option next to the KEY to “text” and then paste the raw JSON in the VALUE

…Of course it would be as simple as exposing a hidden column :slight_smile: