Upload a file using REST API on sharedpoint and naming the file with the date

Nashef, Abdullah 1 Reputation point
2021-08-26T12:00:22.523+00:00

I'm trying to use the method POST to upload a file on SharePoint using REST API. However, I have to make a static name for the file.
Is there a possibility to name the file by the date of the moment the file is uploaded?
I'm using this link:

POST https://{site_url}/_api/web/GetFolderByServerRelativeUrl('/Folder Name')/Files/Add(url='{file_name}', overwrite=true)
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,666 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,673 questions
Microsoft Partner Center API
Microsoft Partner Center API
Microsoft Partner Center: A Microsoft website for partners that provides access to product support, a partner community, and other partner services.API: A software intermediary that allows two applications to interact with each other.
316 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MichaelHan-MSFT 18,016 Reputation points
    2021-08-27T02:14:08.963+00:00

    Hi @Anonymous ,

    If you are using the REST API in JS code to upload a file, you could name the file by the date of the moment like this:

    var now = new Date();  
    var fileName = now.toISOString().slice(0,10) +".docx";  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.