大家好,我正在从事一个涉及从 Intuit Anywhere 获取数据的项目。当使用 Oauth 签名的 url 作为请求发送时,该过程工作正常。有人可以帮助我如何将 xml 请求添加到 IConsumerRequest 的正文中。
OAuthConsumerContext consumerContext = new OAuthConsumerContext
{
ConsumerKey = "consumerkey",
SignatureMethod = SignatureMethod.HmacSha1,
ConsumerSecret = "consumersecret"
};
OAuthSession oSession = new OAuthSession(consumerContext, "https://oauth.intuit.com/oauth/v1/get_request_token",
"https://workplace.intuit.com/Connect/Begin",
"https://oauth.intuit.com/oauth/v1/get_access_token");
oSession.ConsumerContext.UseHeaderForOAuthParameters = true;
oSession.AccessToken = new TokenBase
{
Token = Session["accessToken"].ToString(),
ConsumerKey = "consumerkey",
TokenSecret = Session["accessTokenSecret"].ToString()
};
IConsumerRequest conReq = oSession.Request();
string body = @"<?xml version=""1.0"" encoding=""utf-8""?>
<AccountQuery xmlns=""http://www.intuit.com/sb/cdm/v2"">
<ListIdSet>
<Id idDomain=""QB"">143</Id>
<Id idDomain=""QB"">130</Id>
</ListIdSet>
</AccountQuery>";
conReq = conReq.Get();
conReq = conReq.ForUrl("https://services.intuit.com/sb/account/v2/536779769");
conReq.RequestBody=body;
try
{
conReq = conReq.SignWithToken();
}
catch (Exception ex)
{
throw ex;
}
string header = conReq.Context.GenerateOAuthParametersForHeader();
string serviceResponse = conReq.ReadBody();
我收到一个错误无法发送具有此动词类型的内容正文。有人可以指出错误是什么,或者是否可以对 Web 请求执行相同的操作?请帮忙