Я использую Quickbooks V3 SDK. Он также давал 400 ошибок, так как в октябре 2014 года они изменили свою ссылку с https://quickbooks.api.intuit.com/ на sandbox.quickbooks.api.intuit.com/, после исправления Я могу получить результаты и выполнить операции crud с использованием указанных классов.Quickbooks Http Web Request code дает 400 Server error
ServiceContext serviceContext = getServiceContext(profile);
serviceContext.IppConfiguration.BaseUrl.Qbo = "https://sandbox-quickbooks.api.intuit.com/";
QueryService<Item> ItemQueryService = new QueryService<Item>(serviceContext);
return ItemQueryService.Select(c => c).ToList();
Этот код работает отлично.
Но когда я пытаюсь выполнить ту же операцию, что и запрос JSON с веб-запросом HTTP, это дает мне 400 ошибок. Я вставляю код HTTP-кода ниже.
HttpContext.Current.Session["serviceEndPoint"] = "https://qb.sbfinance.intuit.com/v3/company/" + profile.RealmId +"/item&query=select * from item"; // OAuthConsumerContext consumerContext = OAuthCR(); OAuthSession oSession = OAuthSession(consumerContext); oSession.ConsumerContext.UseHeaderForOAuthParameters = true; oSession.AccessToken = new TokenBase { Token = profile.OAuthAccessToken, ConsumerKey = "qyprdB0F3beIfmSTdvpLG5J46xPGm2", TokenSecret = profile.OAuthAccessTokenSecret }; IConsumerRequest conReq = oSession.Request(); conReq = conReq.Post(); conReq.AcceptsType = "application/json"; conReq = conReq.ForUrl(HttpContext.Current.Session["serviceEndPoint"].ToString()); string header = conReq.Context.GenerateSignatureBase(); try { string res = conReq.ReadBody(); } catch (WebException we) { HttpWebResponse rsp = (HttpWebResponse)we.Response; if (rsp != null) { try { using (StreamReader reader = new StreamReader(rsp.GetResponseStream())) { string res2 = rsp.StatusCode + " | " + reader.ReadToEnd(); } } catch (Exception) { string res = "Status code: " + rsp.StatusCode; } } else { string res = "Error Communicating with Mock Service" + we.Message; } } }