Skip to content

Please, help! How to create an item via web connector in QuickBooks Java #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MarErm27 opened this issue Jul 7, 2020 · 0 comments

Comments

@MarErm27
Copy link

MarErm27 commented Jul 7, 2020

Hello!
I was wondering if you might be able to help, my program is trying to add an invoice but it can't because it can't find an item reference. So I'm trying to add an item, here is an XML that I've done. How to send it to QuickBooks?

<?xml version="1.0"?> <?qbxml version="13.0"?><QBXML><QBXMLMsgsRq onError="continueOnError"><ItemInventoryAddRq><ItemInventoryAdd><Name>Marat</Name><ClassRef><ListID>MAR00610-SD</ListID><FullName> Marat</FullName></ClassRef></ItemInventoryAdd></ItemInventoryAddRq></QBXMLMsgsRq></QBXML>

Here is my Java code that creates the XML:

public String addItem(String itemRefName) throws QBDB.DbException, JAXBException, URISyntaxException, IOException, ClassNotFoundException {
  String[] itemData = itemRefName.split(":", 2);
  System.out.println("=> item name" + itemData[0]);
  System.out.println("=> item ref" + itemData[1]);
  String xml = "";
  QBXML qbXML = new QBXML();
  QBXMLMsgsRq xmlMsgRq = new QBXMLMsgsRq();
  xmlMsgRq.setOnError("continueOnError");
  qbXML.setQBXMLMsgsRq(xmlMsgRq);

  List<Object> reqList = xmlMsgRq.getHostQueryRqOrCompanyQueryRqOrCompanyActivityQueryRq();

  ItemInventoryAddRqType itemAddRq = new ItemInventoryAddRqType();
  reqList.add(itemAddRq);
  ItemInventoryAdd item = new ItemInventoryAdd();
  itemAddRq.setItemInventoryAdd(item);
  item.setName(itemData[0]);
  ClassRef classRef = new ClassRef();
  classRef.setFullName(itemData[0]);
  classRef.setListID(itemData[1]);
  item.setClassRef(classRef);
  xml = getRequestXml(qbXML);
  return xml;
}

Error from invoice: InvoiceQueryRsType: A query request did not find a matching object in QuickBooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@MarErm27 and others