# Uploading a file - getting file undefined error

**URL:** <https://community.postman.com/t/uploading-a-file-getting-file-undefined-error/72150>\
**Category:** Help Hub\
**Tags:** form-data\
**Created:** [December 6, 2024, 12:43am UTC](https://community.postman.com/t/uploading-a-file-getting-file-undefined-error/72150 "2024-12-06T00:43:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bwalsh-mapfreusa](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bwalsh-mapfreusa](https://community.postman.com/u/bwalsh-mapfreusa)\
**Post date:** [December 6, 2024, 12:43am UTC](https://community.postman.com/t/uploading-a-file-getting-file-undefined-error/72150/1 "2024-12-06T00:43:29Z")

</div>

Posting to an api: The file is in my working directory. And the process seems to find it because the Content-Length os 44391… however, Request Body says file: undefined

Host: localhost:8080

Accept-Encoding: gzip, deflate, br

Connection: keep-alive

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

Content-Length: 44391

- ▶Request Body

1. file: undefined

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [December 6, 2024, 10:46am UTC](https://community.postman.com/t/uploading-a-file-getting-file-undefined-error/72150/2 "2024-12-06T10:46:40Z")

</div>

Can you share a screenshot of the request body?

---

<div class="post-metadata">

**Author:** ![bwalsh-mapfreusa](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bwalsh-mapfreusa](https://community.postman.com/u/bwalsh-mapfreusa)\
**Post date:** [December 6, 2024, 5:01pm UTC](https://community.postman.com/t/uploading-a-file-getting-file-undefined-error/72150/3 "2024-12-06T17:01:27Z")

</div>

![image](https://us1.discourse-cdn.com/getpostman/original/3X/2/8/282d2494ebd6ecd2bdd97ab2cdebc7035600d9cd.png)  
I initially had Content-Disposition set and it didn’t work. (The file name matched the file - filename) Also had Content-Type. I was removing those to just have file to eliminate items.

This is the message signature of the api:

public ResponseEntity\<?\> fileUpdate(  
@RequestHeader(value = “Authorization”, required = true) String authorizationHeader,  
@RequestParam Map\<String, String\> queryParams,  
@RequestParam Map\<String, String\> formParams,  
@RequestParam(“file”) MultipartFile file,  
@RequestHeader HttpHeaders headers,  
HttpServletRequest request) {

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [December 9, 2024, 10:26am UTC](https://community.postman.com/t/uploading-a-file-getting-file-undefined-error/72150/4 "2024-12-09T10:26:06Z")

</div>

Is this a POST or a GET request?

I’m assuming POST, so a bit confused by you have queryParams in there which is normally for a GET request.

What do you have in the Params tab?

The way you have the file included looks correct for a POST request.

You might get a better response on Stack Overflow, but you will need to include a lot more information about your API setup.

---

<div class="post-metadata">

**Author:** ![bwalsh-mapfreusa](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bwalsh-mapfreusa](https://community.postman.com/u/bwalsh-mapfreusa)\
**Post date:** [December 9, 2024, 12:48pm UTC](https://community.postman.com/t/uploading-a-file-getting-file-undefined-error/72150/5 "2024-12-09T12:48:30Z")

</div>

Yes it is a POST. Here is a screen shot.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/8/e/8ea6ea129e5396b78d0e1c260f37095d93e64ebb.png)

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [December 9, 2024, 1:33pm UTC](https://community.postman.com/t/uploading-a-file-getting-file-undefined-error/72150/6 "2024-12-09T13:33:10Z")

</div>

Is there any documentation for this API as mixing query parameters and form data is unusual.

I don’t think Postman is the issue here. It looks like something specific with the API setup.

Does it work using another method like cURL?

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [January 8, 2025, 1:33pm UTC](https://community.postman.com/t/uploading-a-file-getting-file-undefined-error/72150/7 "2025-01-08T13:33:55Z")

</div>

Closed on January 8, 2025, 1:33pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
