Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pure C# #26

Closed
Clint66 opened this issue Jul 4, 2017 · 1 comment
Closed

Pure C# #26

Clint66 opened this issue Jul 4, 2017 · 1 comment

Comments

@Clint66
Copy link

Clint66 commented Jul 4, 2017

C# without RestClient

var request = WebRequest.CreateHttp("https://api.whispir.com/messages?apikey=<REPLACE_ME>");
request.Method = "POST";
request.ContentType = "application/vnd.whispir.message-v1+json";
request.Accept = "application/vnd.whispir.message-v1+json";
request.Headers.Add("authorization", "<REPLACE_ME>");

var bytes = Encoding.UTF8.GetBytes("{\"to\":\"<REPLACE_ME>\",\"subject\":\"<REPLACE_ME>\",\"body\":\"<REPLACE_ME>\"}");

request.ContentLength = bytes.Length;

using (var stream = request.GetRequestStream()) {
	stream.Write(bytes, 0, bytes.Length);
	try {
		using (var response = request.GetResponse()) {
			var result = (new StreamReader(response.GetResponseStream())).ReadToEnd();
		}
	}
	catch (WebException wex) {
		using (var response = wex.Response) {
			var error = (new StreamReader(response.GetResponseStream())).ReadToEnd();
		}
	}
}
@nijikokun
Copy link
Contributor

Cleaning up old issues, so closing this out, this should be raised on HTTPSnippet if it is still an issue. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants