2

I'm trying to call the exact target auth api for the first time. I'm getting a 407 Proxy Authentication Required. Can you please let me know where I'm going wrong.

I'm using the following call

https://auth.exacttargetapis.com/v1/requestToken Content-Type: application/json{"ClientId":"myClientID","ClientSecret":"myClientSecret"}

With the above as requestUrl:

   HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
            request.Method = "POST";
            request.Timeout = 1000;
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)

I've also tried the following:

with https://auth.exacttargetapis.com/v1/requestToken in url and "{\"ClientId\":\"myClientIDInHere\",\"ClientSecret\":\"MyclientSecretInHere\"}" in postdata.

It gets as far getRequestStream, but also get a 407 Proxy Authentication Exception public static string WebRequestinJson(string url, string postData) { string ret = string.Empty;

        StreamWriter requestWriter;

        var webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
        try
        {
            if (webRequest != null)
            {
                webRequest.Method = "POST";
                webRequest.ServicePoint.Expect100Continue = false;
                webRequest.Timeout = 20000;

                webRequest.ContentType = "application/json";
                //POST the data.
                using (requestWriter = new StreamWriter(webRequest.GetRequestStream()))
                {
                    requestWriter.Write(postData);
                }
            }

            HttpWebResponse resp = (HttpWebResponse) webRequest.GetResponse();
            Stream resStream = resp.GetResponseStream();
            StreamReader reader = new StreamReader(resStream);
            ret = reader.ReadToEnd();
        }
        catch (Exception e)
        {
            var msg = e.ToString(); 
        }
        return ret;
2
  • What happens if you use something like POSTMAN to do the RESTcall with this clientID and clientSecret? Does that work fine?
    – Timothy
    Oct 14, 2014 at 16:21
  • I used Postman, and when I put the clientId and ClientSecret in the form-data section it worked fine. The exact target documentation suggests POST auth.exacttargetapis.com/v1/requestToken Content-Type: application/json { "clientId": "YOUR_CLIENT_ID_FROM_APP_CENTER", "clientSecret": "YOUR_CLIENT_SECRET_FROM_APP_CENTER" } Is that the same thing as putting it in form-data? Oct 15, 2014 at 14:32

1 Answer 1

1

I have created a Postman Collection which shows you how to use requestToken method correctly; download Collection here. Note that I'm using raw data in my POST request (but form-data also works) and the request includes a Content-Type header with value application/json.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .