0
Отправляю элемент заказа в учетную запись для песочницы quickbooks онлайн с помощью ключей и токенов API. Когда я ищу продукт из Интернета, он дает исключение с кодом ошибки 400 как «Bad Request».
// Sending Order Item To Quickbook Online Account
[NonAction]
public void PostOrderPOS(Order order)
{
string accessToken = "qyprd9yjd4unMlR3ZCrCW8ZfdJS9WwTgm71oh3T2PZBSc8cB";
string accessTokenSecret = "srsBYb9iYnYYWfJaXxL4zLaVJJl8HPfW0AN3sWra";
string consumerKey = "qyprdWz4VaG2kND4E1AEhQaUFCchpM";
string consumerSecret = "bVoRmlN4y7H5cg9NA0oV27pQYB9bzsuCmiYurt70";
OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret);
string appToken = "bd0a230bb9dc9b4321ba9feb899e18471d58";
string companyID = "1403414765"; // realm
ServiceContext context = new ServiceContext(appToken, companyID, IntuitServicesType.QBD, oauthValidator);
DataService service = new DataService(context);
Invoice inv = new Invoice();
inv.AutoDocNumber = true;
inv.AutoDocNumberSpecified = true;
Line[] lines = new Line[order.OrderItems.Count + 2];
int count = 0;
foreach (var orderItem in order.OrderItems)
{
Line line2 = new Line();
line2.Description = orderItem.Product.GetLocalized(x => x.Sku);
line2.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
line2.DetailTypeSpecified = true;
line2.Amount = _currencyService.ConvertCurrency(orderItem.PriceExclTax, order.CurrencyRate);
line2.AmountSpecified = true;
Item qboItem = new Item();
var productname = orderItem.Product.GetLocalized(x => x.Name).ToLower();
IEnumerable<Item> qboItems = service.FindAll(qboItem).Where(x => x.Name.ToLower() == productname) as IEnumerable<Item>; // ***-- Here i Am Getting Error***
int productid = 0;
if (qboItems.Count() > 0)
{
productid = Convert.ToInt32(qboItems.FirstOrDefault().Id);
}
else
{
Item product = new Item();
product.Name = orderItem.Product.GetLocalized(x => x.Name);
product.Description = orderItem.Product.GetLocalized(x => x.Sku);
product.Active = true;
product.ActiveSpecified = true;
product.AssetAccountRef = new ReferenceType()
{
name = "Inventory Asset",
Value = "54"
};
product.UnitPrice = _currencyService.ConvertCurrency(orderItem.UnitPriceExclTax, order.CurrencyRate);
product.UnitPriceSpecified = true;
product.Type = ItemTypeEnum.Inventory;
product.TypeSpecified = true;
ReferenceType refProduct = new ReferenceType();
refProduct.name = "Sales of Product Income";
refProduct.Value = "52";
product.IncomeAccountRef = refProduct;
var addedproduct = service.Add(product);
productid = Convert.ToInt32(addedproduct.Id);
}
}
inv.ShipDate = DateTime.Now.AddDays(7);
inv.ShipDateSpecified = true;
Invoice invoiceAdded = service.Add(inv);
}
Это означает, что некоторые из ваших 'paramter' имеет недопустимый' datatype', чем ожидалось, в '' обслуживания. – Mairaj
Как выглядит ваш HTTP-запрос? Как выглядит полный HTTP-ответ? –
Какой запрос вы говорите о сэре, настройках контекстного объекта? – user2428046