# REST API - How to POST File

**URL:** <https://forum.katalon.com/t/rest-api-how-to-post-file/35192>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [October 23, 2019, 6:10pm UTC](https://forum.katalon.com/t/rest-api-how-to-post-file/35192 "2019-10-23T18:10:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel.tran](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@daniel.tran](https://forum.katalon.com/u/daniel.tran)\
**Post date:** [October 23, 2019, 6:10pm UTC](https://forum.katalon.com/t/rest-api-how-to-post-file/35192/1 "2019-10-23T18:10:07Z")

</div>

I was wondering if anyone could provide input on how to POST a file using REST API. I was having difficulties and am not sure how to proceed.

> RequestObject request = (RequestObject) findTestObject(‘DataImport/postCreationImport’)  
> request.httpHeaderProperties.add(new TestObjectProperty(‘Authorization’, ConditionType.EQUALS, 'bearer ’ + GlobalVariable.token))  
> request.httpHeaderProperties.add(new TestObjectProperty(‘Content-Type’, ConditionType.EQUALS, “multipart/form-data”))  
> request.getRestParameters().add(new TestObjectProperty(‘dryRun’, ConditionType.EQUALS, dryRun.toString()))  
> request.getRestParameters().add(new TestObjectProperty(‘usingExternalRefIds’, ConditionType.EQUALS, usingExternalRefIds.toString()))  
> request.setBodyContent(new HttpFormDataBodyContent([new FormDataBodyParameter(‘file’, filepath, ‘File’)]))

filepath is the path to a .xslx file.

It seems like the data that I get returned has an empty postData field
