Invalid grant: refresh token is invalid

Hi I am trying to get refersh_token, but it gives me this error:

{
“success”: false,
“message”: “Invalid grant: refresh token is invalid”,
“error”: “invalid_grant”
}

This is how the request is generated:
RestClient.post “https://oauth.pipedrive.com/oauth/token”, “grant_type=refresh_token&refresh_token=<refresh_token>”, “Accept”=>"/", “Authorization”=>“Basic <client_id:Client_secret>”, “Content-Length”=>“99”, “Content-Type”=>“application/x-www-form-urlencoded”, “User-Agent”=>“rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.4.2p198”

Eventually, it fails and sometimes it works perfectly. Is there anything that I am doing wrong?

Hey.
I just sent you an email. We will follow up there.
Talk to you soon.