asp.net mvc - Getting Error Code 400 Bad Request While Connecting to my Quickbook API V3 Sandbox Company in nopcommerce V3.60? -
i sending order item quickbooks sandbox account online using api keys , tokens. when searching product online , gives error code 400 exception bad request.
// sending order item 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) ienumerable<item>; // ***-- here 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); }
in servicecontext change line intuitservicestype.qbd intuitservicestype.qbo
Comments
Post a Comment