How to Structure This API Call with Postman

I am trying to submit an API call via the TeamDynamix API and it is a call to upload a file attachment.

From their documentation (https://api.teamdynamix.com/TDWebApi/Home/AboutFileSubmission), you need to structure the API call as follows (there’s also an Auth header with "bearer " but I have that taken care of):

Content-Type: multipart/form-data; boundary=CHANGEME

--CHANGEME
Content-Disposition: form-data; name="aeneid.txt"; filename="aeneid.txt"
Content-Type: application/octet-stream

FORSAN ET HAEC OLIM MEMINISSE IUVABIT
--CHANGEME--

I haven’t encountered a request like this with that “boundary” parameter or whatever it’s called. I’ve been playing around in Postman and I just can’t get it formatted right; the closest I get returns a “415 Unsupported Media Type” response.

What I’ve done is set the Authorization in the Header tab, then go to the Body tab and select “raw” and then paste in that text from above. The HTTP request (click Code, then HTTP) looks fine to me but I’m getting that “415” response. Here’s the HTTP request code generated:

POST /the/api/url HTTP/1.1
Host: the.host.name
Authorization: Bearer *Token goes here*

Content-Type: multipart/form-data; boundary=CHANGEME

--CHANGEME
Content-Disposition: form-data; name="aeneid.txt"; filename="aeneid.txt"
Content-Type: application/octet-stream

FORSAN ET HAEC OLIM MEMINISSE IUVABIT
--CHANGEME--

You can ignore this. I couldn’t figure it out in Postman and eventually found how to do it in C# (RestSharp), which is ultimately what I needed anyway.

On the off chance it helps someone, here’s the main stuff you’d need to do a “multipart/form-data” file upload in RestSharp:

// get the filename from the file path
            string filename = Path.GetFileName(filePath);

            IRestClient client = new RestClient(apiUploadUrl);

            // create the POST request object and assign the Auth token to it
            var request = new RestRequest(Method.POST);
            request.AddHeader("Authorization", "Bearer " + authorizationToken);

            // add the specified file as a byte array
            request.AddFile("fileData", File.ReadAllBytes(filePath), filename);
            request.AlwaysMultipartFormData = true;

            // now add the "boundary" parameter for the specified file, using a randomly-generated (unique) GUID for the name
            request.AddParameter("boundary", Guid.NewGuid().ToString(), ParameterType.GetOrPost);

            // execute api call
            IRestResponse response = null;
            try
            {
                response = client.Execute(request);
            }
            catch (Exception ex)
            {
                return "Error: " + ex.Message;
            }

            // return the response
            return response.Content;