# How to upload file in Kibana Plugin development?

**URL:** https://discuss.elastic.co/t/how-to-upload-file-in-kibana-plugin-development/162056
**Category:** Kibana
**Created:** [December 25, 2018, 9:42am UTC](https://discuss.elastic.co/t/how-to-upload-file-in-kibana-plugin-development/162056 "2018-12-25T09:42:52Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![K\_Chaitanya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/k_chaitanya/32/46387_2.png) [@K\_Chaitanya](https://discuss.elastic.co/u/K_Chaitanya)
#### Post date: [December 25, 2018, 9:42am UTC](https://discuss.elastic.co/t/how-to-upload-file-in-kibana-plugin-development/162056/1 "2018-12-25T09:42:52Z")

</div>

Hi,  
I'm Developing a Kibana Plugin where there is a need to take txt or xlsx files as input from users and process them at backend.

I have generated the sample plugin using kibana plugin generator, in that I'm using euifilepicker component at front end but whenever I send a post request via httpclient in there is a 400 bad request response.

I've tried setting  
'enctype':'multipart/form-data';  
Content-type:multipart/form-data;

but whenever I pass the files returned from the euifilepicker, and hit the url there is 400 bad request.

please help, simple example will be very helpful.

thanks and regards  
Chaitanya

---

<div class="post-metadata">

### Author: ![sebastien](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebastien/32/36119_2.png) [@sebastien](https://discuss.elastic.co/u/sebastien)
#### Post date: [December 25, 2018, 9:50am UTC](https://discuss.elastic.co/t/how-to-upload-file-in-kibana-plugin-development/162056/2 "2018-12-25T09:50:45Z")

</div>

Hi K\_Chaitanya

Have you tried to access your server route API in a REST client (like [Postman](https://www.getpostman.com/)) to see what error is returned?

The url might look something like: `http://localhost:5601/<random>/api/<your-plugin>/<route>`

This would help in understanding what the problem might be.

Cheers.

---

<div class="post-metadata">

### Author: ![K\_Chaitanya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/k_chaitanya/32/46387_2.png) [@K\_Chaitanya](https://discuss.elastic.co/u/K_Chaitanya)
#### Post date: [December 25, 2018, 11:11am UTC](https://discuss.elastic.co/t/how-to-upload-file-in-kibana-plugin-development/162056/3 "2018-12-25T11:11:44Z")

</div>

hi

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/f/3f7ceb499ecccd9d0b58d99e3bb7fb88043c8e38.png)

this was the response when i hit it with postman

---

<div class="post-metadata">

### Author: ![sebastien](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebastien/32/36119_2.png) [@sebastien](https://discuss.elastic.co/u/sebastien)
#### Post date: [December 25, 2018, 11:20am UTC](https://discuss.elastic.co/t/how-to-upload-file-in-kibana-plugin-development/162056/4 "2018-12-25T11:20:35Z")

</div>

Can you go to the "Headers" tab and add `kbn-xsrf` in the _Key_ and `xxx` for the _Value_ and then launch the request again?

---

<div class="post-metadata">

### Author: ![K\_Chaitanya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/k_chaitanya/32/46387_2.png) [@K\_Chaitanya](https://discuss.elastic.co/u/K_Chaitanya)
#### Post date: [December 25, 2018, 8:42pm UTC](https://discuss.elastic.co/t/how-to-upload-file-in-kibana-plugin-development/162056/5 "2018-12-25T20:42:09Z")

</div>

It worked, thanks. I'm able to hit the url in post method with formdata.

if there are any notes regarding kbn-xsrf and why this error was thrown, please share.

---

<div class="post-metadata">

### Author: ![sebastien](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebastien/32/36119_2.png) [@sebastien](https://discuss.elastic.co/u/sebastien)
#### Post date: [December 26, 2018, 8:29am UTC](https://discuss.elastic.co/t/how-to-upload-file-in-kibana-plugin-development/162056/6 "2018-12-26T08:29:00Z")

</div>

This is only needed when developing and accesing the Kibana server api from outside the web application

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 23, 2019, 8:29am UTC](https://discuss.elastic.co/t/how-to-upload-file-in-kibana-plugin-development/162056/7 "2019-01-23T08:29:02Z")

</div>

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