2013-07-17 47 views
0

我想調用數據服務,但每次都收到500錯誤。當我使用API​​ Explorer中的「試用」按鈕進行測試時,它工作正常。答覆很好。但在我的應用程序中,它未能連接。相同的OAuth標頭適用於API,但不適用於該應用程序。Quickbook在線服務提供500個內部服務器?

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; 
} 

我已經嘗試了靜態基本URL這也給了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 

回答

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); 

使用此DataService的對象,嘗試調用任何終端,並檢查其是否工作正常。 如果它工作PLZ捕捉原始HTTP請求使用一些工具,如提琴手。您可以將其與以前的方法進行比較。

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

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

雖然應用上寄宿在7.0或更高版本應該使用靜態基本網址,但你可以查閱一下動態網址你得到相應的貴公司的relam 。 Ref 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

請讓我知道它是怎麼回事。

感謝

+0

謝謝但DevKit不是這裏的一個選項。我們的應用程序一直與QB桌面工作正常。 QB Online有什麼特別之處?設置別的東西?該錯誤消息太泛泛。 – user1949497

+1

接受內容類型錯誤。我爲QB桌面使用「text/xml」。但它不適用於QB Online。 intuitReq.Accept =「application/xml」; – user1949497