Quickbook在线服务提供500内部服务器?

时间:2013-07-17 21:48:41

标签: c# quickbooks intuit-partner-platform quickbooks-online

我正在尝试调用数据服务,但每次都会出现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

2 个答案:

答案 0 :(得分:0)

您可以尝试使用C#devkit,而不是直接调用端点。 (我也会尝试分享一些与此方法相关的代码。)

IDS Devkit下载 - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0100_ipp_.net_devkit/0100_installing_the_ipp_.net_devkit

using Intuit.Ipp.Core;
using Intuit.Ipp.Security;
using Intuit.Ipp.Services;
using Intuit.Ipp.Data;
using Intuit.Ipp.AsyncServices;
using Intuit.Ipp.Data.Qbo; 

OAuthRequestValidator oauthValidator = new OAuthRequestValidator(
"a",
"b",
"c",
"d"
);
ServiceContext context = new ServiceContext (oauthValidator, companyID, IntuitServicesType.QBO);
DataServices objDataService = new DataServices(context);

使用此dataServices对象,尝试调用任何端点并检查它是否正常工作。 如果它工作,PLZ使用像fiddler这样的工具捕获原始的http请求。您可以将其与之前的方法进行比较。

同步通话 - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0100_ipp_.net_devkit/0299_synchronous_calls/0001_data_service_apis

Asyn Call - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0100_ipp_.net_devkit/0300_asynchronous_calls/0001_data_service_apis

虽然登上7.0或更高版本的应用程序应使用静态基本URL,但您只需检查您获得的与公司关联相对应的动态URL。 参考https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/0100_calling_data_services/0010_getting_the_base_url#Getting_the_Base_URL_at_Runtime

请告诉我它是怎么回事。

由于

答案 1 :(得分:0)

您可以从以下位置下载dotnet示例应用: https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/sample_code

只需在web.config中输入您的键值即可设置。