I'm trying to autheniicate using the code below to silverpop although I'm getting a status code of 400 when attempting. Any suggestions as I'm not sure what else to try?! I can see the call going out using Fiddler but I've ran out of ideas. Many thanks
The server is returning the following error message:
Code snippet
var httpWReq = (HttpWebRequest)WebRequest.Create("https://api5.silverpop.com/oauth/token");
var postData = string.Format("&grant_type=refresh_token&client_id={0}&client_secret={1}&refresh_token={2}", config.ClientId, config.ClientSecret, config.RefreshToken);
// Also try this string but I get the same response
//var postData = string.Format("?grant_type=refresh_token&client_id={0}&client_secret={1}&refresh_token={2}", config.ClientId, config.ClientSecret, config.RefreshToken);
var encoding = new ASCIIEncoding();
var data = encoding.GetBytes(postData);
httpWReq.Method = "POST";
httpWReq.ContentType = "x-www-form-urlencoded";
httpWReq.ContentLength = data.Length;
using (var stream = httpWReq.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)httpWReq.GetResponse();
var result = new StreamReader(response.GetResponseStream()).ReadToEnd();
Response from server
The remote server returned an error: (400) Bad Request.


postDatasection doesn't seems good!! shouldn't it start with?instead&? Also try debuging, the value for post data to check whether it contains special character!httpWReq.ContentType = "application/x-www-form-urlencoded";?