我已发送了PUT
个请求并在NullReferenceException
中获得了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;
}
行IRestResponse response = await client.Execute(request);
抛出异常。
OAuth参数绝对不是null
,BaseUri
和lastPartUri
也不是body
。 Dictionary<string, string>
是POST
,也不是空。
GET
和RestSharp
请求可以正常工作。
问题出现在 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()
库中。我怎么能找到它?
这是堆栈跟踪:
styleClass
答案 0 :(得分:2)
这确实是图书馆中的一个错误。开发人员已经修好了。