Subscribe through API .net C#

Posted by Younes on Stack Overflow See other posts from Stack Overflow or by Younes
Published on 2010-03-18T09:02:35Z Indexed on 2010/03/18 9:11 UTC
Read the original article Hit count: 275

Filed under:
|
|
|

I have to submit subscription data to another website. I have got documentation on how to use this API however i'm not 100% sure of how to set this up. I do have all the information needed, like username / passwords etc.

This is the API documentation:

https://www.apiemail.net/api/documentation/?SID=4

How would my request / post / whatever look like in C# .net (vs 2008) when i'm trying to acces this API?

This is what i have now, I think i'm not on the right track:

public static string GArequestResponseHelper(string url, string token, string username, string password)
{

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);

myRequest.Headers.Add("Username: " + username);
myRequest.Headers.Add("Password: " + password);

HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
         Stream responseBody = myResponse.GetResponseStream();

         Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
         StreamReader readStream = new StreamReader(responseBody, encode);

         //return string itself (easier to work with)
         return readStream.ReadToEnd();

Hope someone knows how to set this up properly. Thx!

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET