I've sent a PUT
request and got NullReferenceException
in RestSharp.Portable
:
using (var client = new RestClient(new Uri(BaseUri)))
{
var oAuth1Authenticator = OAuth1Authenticator.ForAccessToken(
OAuthConsumerKey,
OAuthConsumerSecret,
oAuthToken",
oAuthSecret"
);
client.Authenticator = oAuth1Authenticator;
var request = new RestRequest(lastPartUri, httpMethod);
request.AddJsonBody(body);
IRestResponse response = await client.Execute(request);
return response.Content;
}
Line IRestResponse response = await client.Execute(request);
thrown the exception.
OAuth params are definitely not null
, neither are BaseUri
and lastPartUri
. body
is a Dictionary<string, string>
and is not null too.
POST
and GET
requests with the same parameters work just fine.
Looks like the problem is in RestSharp
library. How can I find it?
Here is the stack trace:
at RestSharp.Portable.Authenticators.OAuth1Authenticator.<>c.<AddOAuthData>b__84_3(Parameter p)
at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
at RestSharp.Portable.Authenticators.OAuth1Authenticator.AddOAuthData(IRestClient client, IRestRequest request, OAuthWorkflow workflow)
at RestSharp.Portable.Authenticators.OAuth1Authenticator.PreAuthenticate(IRestClient client, IRestRequest request, ICredentials credentials)
at RestSharp.Portable.RestClientBase.<ExecuteRequest>d__67.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RestSharp.Portable.HttpClient.RestClient.<Execute>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Store.Helpers.MyBookApiConnector.<SendRequest>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Store.Services.DataService.<UpdateReview>d__80.MoveNext()