How to use Commission Junction REST API using .Net

This code sample shows how to use Commission Junction REST API using .Net. The code is very straight forward. Only thing that you need to pay attention to is that you will be passing your user credentials through request header named Authorization. The value for this header is the Developer Key that was assigned to you when you signed up for Commission Junction web services account. This is a mile long string that was sent to you in your mail box as well when you signed up for CJ Web Service access.


class Program
{
 const string ADVERTISERS_LOOKUP_JOINED = 
 "https://advertiser-lookup.api.cj.com/v3/advertiser-lookup?advertiser-ids=joined";
 static void Main(string[] args)
 {
  var reqUrl = string.Format("{0}", ADVERTISERS_LOOKUP_JOINED);
  var webReq = WebRequest.Create(reqUrl) as HttpWebRequest;
  webReq.Headers.Add("Authorization", App.Default.DEVKEY);
  var resp = webReq.GetResponse() as HttpWebResponse;
  // Get the stream associated with the response.
  var receiveStream = resp.GetResponseStream();
  var readStream = new StreamReader(receiveStream, Encoding.UTF8);
  var respText = readStream.ReadToEnd();
  resp.Close();
  readStream.Close();
  if (resp.StatusCode == HttpStatusCode.OK)
  {
   // Parse response.
   Console.WriteLine(respText);
  }
  else
  {
   // what is the error??
  }
  }
}

If you are looking for any help building any tools based on Commission Junction API, contact me. I can guide you through the development using .Net.

comments powered by Disqus

Search

Social

Weather

4.9 °C / 40.9 °F

weather conditions Clear

Monthly Posts

Blog Tags