Sending request with file and text

Describe the bug
I would like to send a request that contains both a file and some meta data about the file.

However, when I create the request, I can’t set the file in the x-www-form-urlencoded so when I send it, it does not have file information.

When I create the request using form-data, it contains the file information, but my server side API receives an empty body

To Reproduce
Steps to reproduce the behavior:

  1. create a new request
  2. set body to form-data
  3. type in ‘image’ for key and select a file for value
  4. type in ‘affiliation’ for key and type in affiliation value
  5. type in ‘name’ for key and type in ‘test’ for value
  6. select “Post”
  7. type in the URL
  8. click the send button

repeat steps, but select x-www-form-urlencoded

Expected behavior
I expect the image data and the other data to come through in my api, but it doesn’t

Here is the result using form-data. NOTE: my back end API has failed validation as it cannot find ‘affiliation’, ‘image’ or ‘name’ in the request (even though it’s present in the form-data)

Here is the result using www-form-urlencoded. NOTE: the back end has created the entry in the DB, but it is missing the ‘image’ portion of the request (it’s not present in the request)

App information (please complete the following information):

  • App Type : REST API
  • Postman Version - latest version
  • OS: windows 7

Additional context
I have searched the web for a way to do this and it seem like there isn’t a good answer

Can you double check by opening the Postman Console that Postman is indeed not sending the other form-data fields as your API complains?

IF it were sending the other form-data fields… then the code would execute correctly… right?
as the only data that I am setting is the relevant data for the API being tested.

@vdespa I met the same situation. I don’t know why postman sent a null object as the body in my case if I was using form-data mode trying to send text data and files data together. If i use the x-www-form-urlencoded to send the text data, it will be ok to send the key-value pairs with only problem is not able to send files together. What is the trick to actually to use form-data mode in current version? I remember few month ago when I used postman, I was able to send files with text together.