Last active
August 29, 2015 14:01
-
-
Save auniverseaway/acafd834c20d7df3d329 to your computer and use it in GitHub Desktop.
RestSharp vs PortableRest (GET / POST)
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
// POST Working in RestSharp | |
var client = new RestClient(url); | |
var request = new RestRequest("/oauth/access_token?client_id=" + clientid + "&client_secret=" + clientsecret, Method.POST); | |
request.AddParameter("grant_type", "password"); | |
request.AddParameter("username", username); | |
request.AddParameter("password", password); | |
client.ExecuteAsync(request, response => | |
{ | |
// Do stuff with the response | |
}); | |
// GET Working in PortableRest | |
BaseUrl = url; | |
var request = new RestRequest("oauth/access_token?client_id=" + clientId + "&client_secret=" + clientSecret, HttpMethod.Get); | |
request.AddQueryString("username", username); | |
request.AddQueryString("password", password); | |
request.AddQueryString("grant_type", "password"); | |
return await ExecuteAsync<Result>(request); | |
// POST *NOT* Working in PortableRest | |
// Error: "Index out of range" | |
BaseUrl = url; | |
var request = new RestRequest("oauth/access_token?client_id=" + clientId + "&client_secret=" + clientSecret, HttpMethod.Post); | |
request.AddHeader("Accept", "application/json, text/javascript, */*; q=0.01"); | |
request.AddQueryString("username", username); | |
request.AddQueryString("password", password); | |
request.AddQueryString("grant_type", "password"); | |
return await ExecuteAsync<Result>(request); | |
// POST NOT working in PortableRest | |
// Error: "Value cannot be NULL, Value: content" | |
BaseUrl = url; | |
var request = new RestRequest("oauth/access_token?client_id=" + clientId + "&client_secret=" + clientSecret, HttpMethod.Post); | |
request.AddParameter("username", username); | |
request.AddParameter("password", password); | |
request.AddParameter("grant_type", "password"); | |
return await ExecuteAsync<Result>(request); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I will add these to the PortableRest unit tests and see what happens. Thanks!