How to create HTTP Post to swap auth code for access token?

Hi all, I’m pretty new to this but I have managed to connect to freeagent
and get my authorization code but I now need to swap that for an access
token.
I am creating an asp.net MVC application so it will all be in c#, This is
what i have got so far:

public void AccessToken(string code)
{
string url = @“https://api.freeagent.com/v2/token_endpoint”;
WebClient client = new WebClient();
string credentials = Convert.ToBase64String(Encoding.ASCII.
GetBytes(ApiKey + “:” + ApiSecret));
client.Headers[HttpRequestHeader.Authorization] = "Basic " +credentials
;
client.Headers[HttpRequestHeader.Accept] = “application/json”;
client.Headers[HttpRequestHeader.ContentType] =
“application/x-www-form-urlencoded”;
client.Headers[HttpRequestHeader.UserAgent] = “Java/1.6.0_33”;
client.Headers[HttpRequestHeader.Host] = “api.freeagent.com”;
client.Headers[HttpRequestHeader.Connection] = “close”;
client.Headers[“grant_type”] = “authorization_code”;

        var result = client.DownloadString(url);
    }

I think the problem I am having is trying to add the grant_type. This is
what I was shown to add:

grant_type=authorization_code&code=12P3AsFZXwXjd7SLOE1dsaX8oCgix&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Foauth

Can anyone offer any support with this, it is also possible that this is all wrong :slight_smile:

Thanks in advance
Brian