How do I send a file via Post?

Hello everyone. I’m trying to send a file to a software platform called Ironclad. I’ve read their API documentation and talked to their support but I still can’t make it work. This has to be a problem with the way I’m using Postman so maybe you can help. I will be forever in your debt!

This is what their support tells me I need to send:

{
    "template": "<template_id>", // e.g., "681e2c9c1056d2e0806279a7"
    "attributes": {
      "draft": [
        {
          "file": {
            "Content-Type": "application/pdf",
            "File content": "<base64_encoded_file>",
            "Original file name": "<filename.pdf>"
          }
        }
      ],
      "counterpartyName": "Test Corp",
      "requesterEmail": "<your_email>"
      // Add other required attributes
    },
    "form": "launch"
  }

And here is how I configured Postman:

That body doesn’t look right.

Can you please share the link to the documentation?

Your example looks like JSON. So I would maybe try changing the body to raw\JSON but I would hope that the documentation tells you what should be used to avoid guessing.

It’s also asking for a base64 encoded file, not an attachment. Base64 will look like a long string of characters (basically text).

Hi Mike and thanks for your response! Linking the documentation below but a couple more clues that may help.

  1. The code I provided above came from their support and doesn’t appear to match their documentation. (Unless I’m reading it wrong)
  2. I’m using the form-data because I need to upload a file in the test and I don’t know how to do that with the RAW tab. The file is sitting on my desktop so not sure how to pipe that into the RAW tab.

API Reference

Additional details about launching a workflow (what I’m trying to accomplish with this API call) can be found here:

Workflow Launch

The instructions are under 3.5.1 Multipart/Form-Data Requests (Binaries).

You do need to use form-data but you should only have two keys. You may have additional keys if you are sending multiple binary files.

One key called “data” with your JSON payload in it. (Use an online JSON formatter to minify the code).

Then a separate key for each binary file that you want to attach. The key name needs to match the file names from the attributes object in the JSON payload.

I tried this originally and it gave me the same error as shown in my screenshot. That’s when I reached out to support and they gave me this entirely different code I pasted above. Let me do this again and see what error comes back.

I really appreciate your responses on this.

Have you tried it with raw\JSON and no attachments?

Just to get a basic workflow working.

Then move onto the form data with attachments.

I guess you can try their method.

{
    "template": "<template_id>", // e.g., "681e2c9c1056d2e0806279a7"
    "attributes": {
      "draft": [
        {
          "file": {
            "Content-Type": "application/pdf",
            "File content": "<base64_encoded_file>",
            "Original file name": "<filename.pdf>"
          }
        }
      ],
      "counterpartyName": "Test Corp",
      "requesterEmail": "<your_email>"
      // Add other required attributes
    },
    "form": "launch"
  }

This would be a raw\JSON request (not form data).

You would change the “File content” value to a variable, and this will need to contain a base64 encoded string (not the actual attachment).

You can use an online converter to create the base64 string for you.

However as you have already mentioned, this doesn’t align with the documentation.

Yeah here is the original test I did using the documentation and the screenshots so you can verify I’m not messing this up:

Let me try the example you just sent in your prior message. I didn’t know you could convert a file to a base64 encoded string so I will have to research that real quick.

Well I got a little further but a different error. Have you seen an error like this?

That error is pointing to the first object in the draft array.

What part of that object its not liking is uncertain and probably someone you might need to run past the supplier of the API.

Try removing the quotes from the File content value. The variable should already be a string. (Sometimes you need to add quotes, sometimes you don’t).

Also check the console logs to ensure what is being sent matches what you think it should be sending.

In regards to the first attempt using form data. Does the template ID have to be valid? (Or are you just obfuscating the value for posting on the forum)

Have you tried sending a GET request as per 3.1. Retrieve the Workflow’s Launch Form Schema - hopefully that should return the correct template ID to use.

Yes I was able to do a GET on the schema to obtain the correct template ID. Yes, I am obfuscating for the forum post but the correct template ID is in the request. Without it, I get an error that the record was not found. So I think I’m good on that front.

I tried removing the quotes in the RAW and it errors out with a JSON error. I put them back in and checked the console for the request body and it looks correct to me. HEre is what It shows:

{
    "template": "<removed for forum post>",
    "attributes": {
        "draft": [
            {
                "file": {
                    "Content-Type": "application/pdf",
                    "File content": "<removed for forum post>",
                    "Original file name": "myDoc1.docx"
                }
            }
        ],
        "counterpartyName": "Acme",
        "counterpartySignerEmail": "[email protected]",
        "counterpartySignerName": "Bob Acme"
    },
    "form": "launch"
}

Also good to note that I had to put quote in the variable definition or else it doesn’t pass the entire variable value. I tried both with / without the quotes and still get the same error.

I can only recommend sharing what you currently have with the supplier for advice as this appears to be API specific.

You’ve tried what it says in the documentation plus the alternative they provided.

Do they have their own forums?

Unfortunately they don’t have a forum so I’m waiting for responses from their support which is delayed 24 hours every time I message them. But I agree we seem to have hit a dead end.

I really appreciate you giving this a shot :slight_smile: Let me know if there is somewhere I can send you a tip for your time.

When you contact them next, ask them if they can provide a cURL example.

As you should just be able to imort that example straight into Postman and it should setup the request correctly.

Oh my I just got it to work. I re-read their documentation, ignored what support said, and added in some tidbits you gave me. The solution is that the API wants to receive the two parts you mentioned… a “data” part and the actual file in a separate part. But the JSON within the data part is very particular and doesn’t match their API reference.

I can’t thank you enough for your help on this. Let me know if I can send you anything for your time :slight_smile: I know you won’t ask for it but man you’ve saved my bacon on this.

1 Like