# Attachment file via REST API call

**URL:** <https://forum.flowable.org/t/attachment-file-via-rest-api-call/3928>\
**Category:** Flowable Engine\
**Created:** [May 23, 2019, 2:33pm UTC](https://forum.flowable.org/t/attachment-file-via-rest-api-call/3928 "2019-05-23T14:33:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![earion](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/earion/32/1233_2.png) [@earion](https://forum.flowable.org/u/earion)\
**Post date:** [May 23, 2019, 2:33pm UTC](https://forum.flowable.org/t/attachment-file-via-rest-api-call/3928/1 "2019-05-23T14:33:42Z")

</div>

Hello everyone,

We are analyzing Flowable as a central process server to any application that need a workflow in our organization.

I have a spring boot app that read a form and sends it. If the field is a file type a POST to /flowable-task/content-api/content-service/content-items/ with this JSON request (example) is sent

> ```
> {
> "name" : "test_doc.pdf",
> "file" : "JVBERi0xLjYNJeLjz9MNCjE4IDAgb2JqDTw8L0xpbmVhcml6ZWQg..."
> }
> 
> ```

And a 201 and and id is returned. “file” is the binary array content of the file.  
But if I request a GET to /flowable-task/content-api/content-service/content-items/[id]/data I receive

> ```
> {
> "message": "Internal server error",
> "exception": "No data available for content item [id]"
> }
> 
> ```

If I request a GET to /flowable-task/content-api/content-service/content-items/[id] I receive

> ```
> {
> "id": [id],
> "name": "test_doc.pdf",
> "mimeType": "application/pdf",
> "taskId": null,
> "processInstanceId": null,
> "contentStoreId": null,
> "contentStoreName": null,
> "contentAvailable": false,
> "tenantId": "",
> "created": "2019-05-23T15:19:12.357+02:00",
> "createdBy": "jack",
> "lastModified": "2019-05-23T15:19:12.357+02:00",
> "lastModifiedBy": "jack",
> "url": "http://xxx:8080/flowable-task/content-api/content-service/content-items/[id]"
> }
> 
> ```

One thing that bothers me is the property “contentAvailable”: false but I can’t change it to true. The file uploaded directly to the form in /flowable-tasks/ have the property “contentAvailable” : true and can be downloaded correctly.

The only “documentation” that I found is: [https://github.com/flowable/flowable-engine/blob/master/docs/public-api/references/openapi/content/flowable-oas-content.yaml](https://github.com/flowable/flowable-engine/blob/master/docs/public-api/references/openapi/content/flowable-oas-content.yaml)

Anyone knows how this request to /flowable-task/content-api/content-service/content-items is done? What’s the JSON format of the request?

Thank you in advance

---

<div class="post-metadata">

**Author:** ![earion](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/earion/32/1233_2.png) [@earion](https://forum.flowable.org/u/earion)\
**Post date:** [May 28, 2019, 7:31am UTC](https://forum.flowable.org/t/attachment-file-via-rest-api-call/3928/2 "2019-05-28T07:31:12Z")

</div>

Ok, solved it!

The value of “file” in the JSON request has to be a FileSystemResource (not a binary array as documented).  
An example done with springboot could be:

```
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
				
MultiValueMap<String, Object> body = new LinkedMultiValueMap<String, Object>();
body.add("name", part.getSubmittedFileName());
body.add("file", new FileSystemResource(tmpFile));
body.add("mimeType", part.getContentType());
				
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers);
				
ResponseEntity<String> answer =	restTemplate.postForEntity(URL_UPLOAD_FILE, requestEntity, String.class);

```

Regards
