使用QB Online API v3添加客户时的401

时间:2014-03-04 03:09:41

标签: intuit-partner-platform quickbooks-online

当我尝试使用QB Online API v3添加客户时,我一直收到401。 xml在API Explorer中工作,我可以从我的程序中查询客户。我就是不能发帖。我做错了什么?

        string reqBody = "<Customer xmlns=\"http://schema.intuit.com/finance/v3\" domain=\"QBO\" sparse=\"false\"><DisplayName>Empire Records</DisplayName>"
                + "<BillAddr><Line1>201 S King St</Line1><City>Seattle</City><CountrySubDivisionCode>WA</CountrySubDivisionCode><PostalCode>98104</PostalCode></BillAddr>"
                + "<PrimaryPhone><FreeFormNumber>425-867-5309</FreeFormNumber></PrimaryPhone><PrimaryEmailAddr><Address>helpme@thefly.con</Address></PrimaryEmailAddr></Customer>";

        IConsumerRequest req = session.Request();
        req = req.Post().WithRawContentType("application/xml").WithRawContent(System.Text.Encoding.ASCII.GetBytes(reqBody));
        req.AcceptsType = "application/xml";
        string response = req.Post().ForUrl("https://quickbooks.api.intuit.com/v3/company/" + realmID + "/customer").ToString()

1 个答案:

答案 0 :(得分:2)

OAuthConsumerContext consumerContext1 = new OAuthConsumerContext 
{ 
ConsumerKey = ConfigurationManager.AppSettings["consumerKey"].ToString(), 
SignatureMethod = SignatureMethod.HmacSha1, 
ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"].ToString() 
};  

OAuthSession oSession1 = new OAuthSession(consumerContext1,     "https://oauth.intuit.com/oauth/v1/get_request_token", 
"https://workplace.intuit.com/Connect/Begin", 
"https://oauth.intuit.com/oauth/v1/get_access_token"); 

oSession1.ConsumerContext.UseHeaderForOAuthParameters = true;