Refresh token error

Hi everyone,

I am using the freeAgent API for a project but i’ve got some troubles refreshing the token.
I’m doing it like in the documentation but i have an “invalide grant_type” error.

Here is my request, if you can help me :

var options = {
                   method: 'POST',
                   headers: {
                       'Content-Type': 'application/json',
                       'Accept': 'application/json',
                       'Authorization': 'Basic'
                       //,"grant_types": ["refresh_token", "authorization_code"],
                   }
               }

               var url = `https://api.freeagent.com/v2/token_endpoint?grant_type=refresh_token&refresh_token=${refresh_token}&client_id=${ client_id}&client_secret=${ client_secret }`;

               https.request(url, options, function(res) {
                   res.on('data', function(data){
                       process.stdout.write(data);
                   });
               }).end();

thank you in advance

Hi there,

As a first pass I’d be tempted to direct your integration to a service such as Postbin and repeat your refresh request. This service allows you to see the request that’s received by the server, which should allow you to spot any difference(s) between our documentation and the request being sent by your code.

If you’re still having trouble, feel free to post back here, though please could you share all of the information outlined in this post so we can more easily find your request(s) in our logs:

Kind regards,
Dave J

Hi again,

Thank you for your awnser. I’m pretty new here sorry ^^
I will add more informations there. I am using a sandbox account, my app name is APITEST2.
You already have my request but let me know if I have something to add.
The response I get is the following :
Status: 400
{"error":"invalid_grant"}
I have tried Postbin liked you said but I don’t know if this can really help me.
Maybe I made a mistake I can’t spot I don’t know.

Thank you again