How to change name of result of rest export? I have a custom entity (ContractSubscription) created in a custom module (amap).
One of its fields (contract_id) is a link to another custom entity (Contract) of the same module.  

I created a View to export content of ContractSubscription as a csv file using REST Export.
Among the settings of the view, I have:  


Path: /amap/contract/export
Contextual filters: 'Contract subscription : Contract' (this allows me to view only the subscriptions related to a specific contract)


When I go to mysite/amap/contract/export/2, I have the expected result that I can save locally:  

  

As far as I understand, the name of the result is defined by the actual path when the view is executed, i.e. '2' which is the end of the path (in fact the value of the contextual filter).  

I'd like to have something like 'Contract2.csv' instead of '2'.
How can I do that?
The HTTP header Content-Disposition will suggest the filename the browser will save as. What's needed here is to make the REST export to add the HTTP header. 

It turns out there's an existing issue for the CSV Serialization module. The current patch in the issue will take the last part of the URL after the slash and appends .csv to it (e.g. 2.csv in your example). You could modify the patch to use whatever filename you want to use for your CSV export.