# How to use joplin api \`/resources/:id/file\`?

**URL:** https://discourse.joplinapp.org/t/how-to-use-joplin-api-resources-id-file/11333
**Category:** Development
**Created:** [29 September 2020 01:21 UTC](https://discourse.joplinapp.org/t/how-to-use-joplin-api-resources-id-file/11333 "2020-09-29T01:21:11Z")
**Posts on this page:** 1
**Page:** 2

<div class="post-metadata">

### Author: ![rxliuli](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/rxliuli/32/4083_2.png) [@rxliuli](https://discourse.joplinapp.org/u/rxliuli)
#### Post date: [10 October 2020 10:56 UTC](https://discourse.joplinapp.org/t/how-to-use-joplin-api-resources-id-file/11333/21 "2020-10-10T10:56:49Z")

</div>

There is a new reply, it seems to be an error reported by joplin

```ts
    const path = resolve(__dirname, '../resource/resourcesByFileId.png')
    function getFormData() {
      const fd = new FormData()
      const title = 'image title'
      fd.append('props', JSON.stringify({ title: title }))
      fd.append('data', readFileSync(path))
      return fd
    }
    it('test create by axios', async () => {
      const fd = getFormData()
      const resp = await axios.post(
        ApiUtil.baseUrl('/resources'),
        fd.getBuffer(),
        {
          headers: fd.getHeaders(),
        },
      )
      console.log('resp.data: ', resp.data)
    })

```

![image](https://user-images.githubusercontent.com/24560368/95653255-ffe9a900-0b29-11eb-87b0-740d3c544229.png)  
 ![image](https://user-images.githubusercontent.com/24560368/95653384-fdd41a00-0b2a-11eb-9785-8776224733dd.png)

Reproduce the code: [joplin-api/test/api/ResourceApi.test.ts at 34f3b99ea6c97741e88fc964eed6a3eb5fa5ca55 · rxliuli/joplin-api · GitHub](https://github.com/rxliuli/joplin-api/blob/34f3b99ea6c97741e88fc964eed6a3eb5fa5ca55/test/api/ResourceApi.test.ts#L50)

> ref: [axios upload form-data error · Issue #3325 · axios/axios · GitHub](https://github.com/axios/axios/issues/3325#issuecomment-706524238)

[Previous page](https://discourse.joplinapp.org/t/how-to-use-joplin-api-resources-id-file/11333.md?page=1)
