Using Wufoo API with ASP.NET C#

I’ve just completed my basic Proof of Concept project for accessing the Wufoo API via ASP.NET C#.  I’m including the project here so others can hopefully get off the ground quicker with similar projects.  Here’s the basic code:

Wufoo C# Proof of Concept Source Code

Code Snippet
  1. string wufooAPIKey = "YOUR API KEY";
  2.  
  3.  
  4. // https://fishbowl.wufoo.com/api/v3/users.json
  5. StringBuilder url = new StringBuilder();
  6. url.Append("https://YOURSUBDOMAIN.wufoo.com/api/v3/users.json");
  7. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url.ToString());
  8. string authInfo = wufooAPIKey + ":" + "footastic";
  9. authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
  10. request.Headers["Authorization"] = "Basic " + authInfo;
  11.  
  12. using (var webResponse = (HttpWebResponse)request.GetResponse())
  13. {
  14.  
  15.     using (var reader = new StreamReader(webResponse.GetResponseStream()))
  16.     {
  17.         var objText = reader.ReadToEnd();
  18.         WufooUserJSON deserializedProduct = JsonConvert.DeserializeObject<WufooUserJSON>(objText);
  19.     }
  20.  
  21. }

And the JSON classes for the User REST service:

Code Snippet
  1. public class WuFooUser
  2. {
  3.     public string User { get; set; }
  4.     public string Email { get; set; }
  5.     public string TimeZone { get; set; }
  6.     public string Company { get; set; }
  7.     public string IsAccountOwner { get; set; }
  8.     public string CreateForms { get; set; }
  9.     public string CreateReports { get; set; }
  10.     public string CreateThemes { get; set; }
  11.     public string AdminAccess { get; set; }
  12.     public string Image { get; set; }
  13.     public string ApiKey { get; set; }
  14.     public string LinkForms { get; set; }
  15.     public string LinkReports { get; set; }
  16.     public string Hash { get; set; }
  17.     public string ImageUrlBig { get; set; }
  18.     public string ImageUrlSmall { get; set; }
  19.     public string HttpsEnabled { get; set; }
  20. }
  21.  
  22. public class WufooUserJSON
  23. {
  24.     public List<WuFooUser> Users { get; set; }
  25. }

Requirements:

Newtonsoft JSON

Posted in api, asp.net, coding, integration

Leave a Reply

Your email address will not be published. Required fields are marked *

*