Using Api to submit userdata to external party
- by Younes
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();