# Attach File in form through REST API

**URL:** <https://forum.flowable.org/t/attach-file-in-form-through-rest-api/3227>\
**Category:** Flowable Engine\
**Created:** [January 12, 2019, 12:02pm UTC](https://forum.flowable.org/t/attach-file-in-form-through-rest-api/3227 "2019-01-12T12:02:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![virajak](https://avatars.discourse-cdn.com/v4/letter/v/e480ec/32.png) [@virajak](https://forum.flowable.org/u/virajak)\
**Post date:** [January 12, 2019, 12:02pm UTC](https://forum.flowable.org/t/attach-file-in-form-through-rest-api/3227/1 "2019-01-12T12:02:43Z")

</div>

I have simple form with few text fields and one file upload. I can easily fill the form and submit it without attachment thriugh REST API. How do I attach the file to this task?

For filling text fields IA m calling :  
http:/localhost:8080/flowable-task/process-api/form/form-data  
and for attachment I am using :  
[http://admin:test@localhost:8080/flowable-task/process-api/form/form-data](http://admin:test@localhost:8080/flowable-task/process-api/form/form-data)

I am tying in this way:

LinkedMultiValueMap\<String, Object\> map = new LinkedMultiValueMap\<\>();  
FileSystemResource value = new FileSystemResource(new File(fileTouploadFullPath));  
map.add(“file”, value);  
HttpHeaders headers = new HttpHeaders();  
headers.setContentType(MediaType.MULTIPART\_FORM\_DATA);  
headers.set(“Authorization”, "Basic " + base64ClientCredentials);  
HttpEntity\<LinkedMultiValueMap\<String, Object\>\> requestEntity = new HttpEntity\<\>(map, headers);  
RestTemplate restTemplate = new RestTemplate();  
ResponseEntity resposne = restTemplate.exchange(“[http://localhost:8080/flowable-task/runtime/tasks/"+taskId+"/attachments](http://localhost:8080/flowable-task/runtime/tasks/%22+taskId+%22/attachments)”, HttpMethod.POST, requestEntity, String.class);

System.out.println(resposne.getStatusCode()+" "+resposne.getBody());

I am getting Response Status 302 FOUND with empty body. In the background process and task is created with no attachment

---

<div class="post-metadata">

**Author:** ![virajak](https://avatars.discourse-cdn.com/v4/letter/v/e480ec/32.png) [@virajak](https://forum.flowable.org/u/virajak)\
**Post date:** [January 14, 2019, 5:13am UTC](https://forum.flowable.org/t/attach-file-in-form-through-rest-api/3227/2 "2019-01-14T05:13:44Z")

</div>

can someone help… I want to upload file in form by calling REST API. How can it be done?

---

<div class="post-metadata">

**Author:** ![xcaptain](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/xcaptain/32/1286_2.png) [@xcaptain](https://forum.flowable.org/u/xcaptain)\
**Post date:** [January 14, 2019, 6:12am UTC](https://forum.flowable.org/t/attach-file-in-form-through-rest-api/3227/3 "2019-01-14T06:12:13Z")

</div>

> <https://github.com/flowable/flowable-engine/issues/1471#issuecomment-452239852>

You can use

```auto
POST flowable-task/content-api/content-service/content-items

```

to upload attachments.
