# Download file is no longer works with SmartAction (with POST http call)

**URL:** <https://community.forestadmin.com/t/download-file-is-no-longer-works-with-smartaction-with-post-http-call/1508>\
**Category:** Help me!\
**Tags:** howtos, setup\
**Created:** [December 23, 2020, 5:17pm UTC](https://community.forestadmin.com/t/download-file-is-no-longer-works-with-smartaction-with-post-http-call/1508 "2020-12-23T17:17:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathieu\_Breton](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/mathieu_breton/32/63_2.png) [@Mathieu\_Breton](https://community.forestadmin.com/u/Mathieu_Breton)\
**Post date:** [December 23, 2020, 5:17pm UTC](https://community.forestadmin.com/t/download-file-is-no-longer-works-with-smartaction-with-post-http-call/1508/1 "2020-12-23T17:17:43Z")

</div>

## Expected behavior

As described in the documentation, it’s possible to download a file on a smart action response using the POST Http verb :  
[https://docs.forestadmin.com/documentation/reference-guide/actions/create-and-manage-smart-actions#downloading-a-file](https://docs.forestadmin.com/documentation/reference-guide/actions/create-and-manage-smart-actions#downloading-a-file)

## Actual behavior

Try to create a smart action as described in the documentation:  
[https://docs.forestadmin.com/documentation/reference-guide/actions/create-and-manage-smart-actions#downloading-a-file](https://docs.forestadmin.com/documentation/reference-guide/actions/create-and-manage-smart-actions#downloading-a-file)

It is important to use a Smart Action with POST and not GET.  
When you call your smart action, the server returns an HTTP response containing a valid response with the file attached.  
But, the FrontAdmin interface tries to parse into JSON the body in the HTTP response. Obviously, is not parsable, and the interface display an error message.  
There is a “workaround”, if you switch your Smart action in GET. It works, but you don’t have the input parameters …

## Failure Logs

Please include any relevant log snippets, if necessary.

 ![Screen Shot 2020-12-23 at 18.13.25](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/3/36aeac848628247ba82b7e6e098ed5e5a9b50c93.png)

## Context

Please provide any relevant information about your setup.

- Package Version: tested on 6.6.2 and 5.7.0
- Express Version: 4.17.1
- Sequelize Version: 5.22.3
- Database Dialect: Postgres
- Database Version: 11
- Project Name: Swan Back-Office

---

<div class="post-metadata">

**Author:** ![rap2h](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/rap2h/32/25_2.png) [@rap2h](https://community.forestadmin.com/u/rap2h)\
**Post date:** [December 24, 2020, 9:49am UTC](https://community.forestadmin.com/t/download-file-is-no-longer-works-with-smartaction-with-post-http-call/1508/2 "2020-12-24T09:49:26Z")

</div>

Hi @Mathieu_Breton 👋 Thank you for your feedback!

I just tried this, with a `User` model, it seems it works (using `POST`):

```javascript
// In file `forest/user.js`, don't forget "download true".
 { name: 'Generate invoice', download: true },

// In a `routes/user.js`
router.post(
  '/actions/generate-invoice',
  permissionMiddlewareCreator.smartAction(),
  (req, res, next) => {
    let options = {
      root: __dirname + '/../public/',
      dotfiles: 'deny',
      headers: {
        'Access-Control-Expose-Headers': 'Content-Disposition',
        'Content-Disposition': 'attachment; filename="favicon.png"'
      }
    };

    let fileName = 'favicon.png';
    res.sendFile(fileName, options, (error) => {
      if (error) { next(error); }
    });
  });

```

👉 Could you share a simplified version of the code in your smart action definition and route? Maybe there is something missing.

---

<div class="post-metadata">

**Author:** ![Mathieu\_Breton](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/mathieu_breton/32/63_2.png) [@Mathieu\_Breton](https://community.forestadmin.com/u/Mathieu_Breton)\
**Post date:** [February 12, 2021, 4:55pm UTC](https://community.forestadmin.com/t/download-file-is-no-longer-works-with-smartaction-with-post-http-call/1508/3 "2021-02-12T16:55:43Z")

</div>

Hi guys,

Sorry for the delay, I figured out what it was my problem.  
It appear the download feature doesn’t work when the server responds with the HTTP code 201.
