visual-studio-coderest-clientvscode-restclient

VSCode REST client : how to get now date


I am doing some request with rest client extension in VScode I would like to know if there is a way to get the current date and to use it in a request

It would be something like

# CreateLesson
# @name CreateLesson
POST {{baseUrl}}/Lesson/CreateLesson HTTP/1.1
Content-Type: application/json
Authorization: Bearer {{authToken}}

{
    "Name": "Maths",
    "DateCreation": {{__now__}},
    "Room": "B23"
    "NbHours": 2,
}
###

Do you know how to do it please?


Solution

  • This solution works

    ###
    
    @authToken = {{tokenAPI.response.body.token}}
    @createdAt = {{$datetime iso8601}}
    
    ###
    # CreateLesson
    # @name CreateLesson
    POST {{baseUrl}}/Lesson/CreateLesson HTTP/1.1
    Content-Type: application/json
    Authorization: Bearer {{authToken}}
    
    {
        "Name": "Maths",
        "DateCreation": "{{createdAt}}",
        "Room": "B23"
        "NbHours": 2,
    }
    ###