我正在尝试调用数据服务,但每次都收到 500 错误。当我在 API Explorer 中使用“试用”按钮进行测试时,它起作用了。反应很好。但在我的应用程序中,它无法连接。相同的 OAuth 标头适用于 API,但不适用于应用程序内部。
String urlReq = "https://qbo.sbfinance.intuit.com/resource/companymetadata/v2/" + intuitRealmID; //static baseURL
Uri uriToIntuit = new Uri(urlReq);
HttpWebRequest intuitReq = (HttpWebRequest)WebRequest.Create(uriToIntuit);
intuitReq.Method = "GET";
intuitReq.ContentType = "text/xml";
intuitReq.ContentLength = 0;
intuitReq.Accept = "text/xml";
OAuthUtils.signRequest(intuitReq, ap.ConsumerKey, ap.ConsumerSecret, rToken.Token,rToken.TokenSecret);
HttpWebResponse httpResponse = (HttpWebResponse)(intuitReq.GetResponse());
...
public static void signRequest(HttpWebRequest request, string consumerKey, string consumerSecret, string token, string tokenSecret)
{
string normalizedUrl;
string normalizedRequestParameters;
string timeStamp = OAuthUtils.GenerateTimeStamp();
string nonce = OAuthUtils.GenerateNonce();
OAuthConsumerBase consumerBase = new OAuthConsumerBase();
string signature = consumerBase.GenerateSignature(
request.RequestUri,
null, // callback,
null, // verifier,
consumerKey,
consumerSecret,
token, // token,
null, // type,
tokenSecret, // tokenSecret,
request.Method,
timeStamp,
nonce,
null, // status,
out normalizedUrl,
out normalizedRequestParameters
);
string authHeader = OAuthRequest.GenerateAuthHeader(
nonce,
timeStamp,
signature,
token,
consumerKey,
null, // verifier
null, // callback
"HMAC-SHA1", // signature type
"1.0" // version
);
request.Headers[HttpRequestHeader.Authorization] = authHeader;
}
我已经尝试了静态 baseURL,它也给出了 500 错误。 https://qbo.intuit.com/qbo1/rest/user/v2/
OAuth oauth_version=\"1.0\", oauth_nonce=\"c830ffa8338b4d6fa0b3e8d03f144642\", oauth_timestamp=\"1374015013\", oauth_consumer_key=\"qyprdpwcmwYdE7nfBkG4Mb0t65ufH8\", oauth_token=\"qyprdTnNWcIBorQk9L93o8ERKPZI3ELoBUHBrULzvsxPsPMU\", oauth_signature_method=\"HMAC-SHA1\", oauth_signature=\"Ws0WpQmV9aAzaFHw%2B6wMC5aidBk%3D\"" string