Last active
September 19, 2017 19:27
-
-
Save shagamemnon/dfa272aae27f3cb05c9bddcd16d9d675 to your computer and use it in GitHub Desktop.
Example C# HTTP Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MyNamespace { | |
public class MyRequest { | |
private async Task<bool> Request () { | |
// Replace MY_TOKEN with a test token object id | |
string url = "https://api.stripe.com/v1/charges?amount=1000¤cy=usd&source=MY_TOKEN&description=Test%20charge%20to%20text%40example.com"; | |
// Replace MY_SECRET_KEY with test secret key (e.g. sk_test_...) | |
HttpWebRequest request = (HttpWebRequest)WebRequest.Create (new Uri(url)); | |
request.Headers.Add("Authorization", "Bearer MY_SECRET_KEY"); | |
request.Method = "POST"; | |
using (WebResponse response = await request.GetResponseAsync ()) { | |
using (Stream stream = response.GetResponseStream ()) { | |
return true; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment