Solved

Trying to find items in Acumatica by vendor and vendor code/alternate ID using REST API

  • 9 October 2023
  • 2 replies
  • 158 views

Userlevel 2

I’m writing a script to automatically process electronic invoices that come in through email and perform several actions after parsing up the invoices and extracting information from them.  I’m kind of new to REST API (I am very familiar with SQL) and so I was wondering how I could write a query that would return the InventoryID of the item based off 1) UPC (barcode) or 2) vendor and vendor code/alternate ID, which are things that are typically included on invoices.  My code is below:

 

Private Sub test()
  Dim ResponseText As String
  
   If RESTQuery("Default/22.200.001/StockItem?$expand=CrossReferences&$select=InventoryID&$filter=CrossReferences/VendorOrCustomer%20eq%20'V000000247'%20and%20CrossReferences/AlternateID%20eq%20'8836'", ResponseText) <> 0 Then
    Debug.Print "Query failed!"
  Else
    Debug.Print "Query successful!"
  End If
End Sub
 

The first part of the error message that is returned is:

 

{"message":"An error has occurred.","exceptionMessage":"The parent value for a property access of a property 'VendorOrCustomer' is not a single value. Property access can only be applied to a single value.","exceptionType":"Microsoft.Data.OData.ODataException","stackTrace":"  …

 

I am trying to write something to the effect of SELECT InventoryID FROM StockItem WHERE (VendorOrCustomer = 'V000000247') AND (AlternateID = '8836')

 

Thanks in advance for any help with this!

icon

Best answer by RohitRattan88 17 October 2023, 15:50

View original

2 replies

Userlevel 7
Badge +9

Hi @FredL Please find the below sample to construct the REST API url.
https://stackoverflow.com/questions/48158552/acumatica-inventory-summary-inquiry-all-items-via-rest-api

Userlevel 7
Badge +4

 
   If RESTQuery("Default/22.200.001/StockItem?$expand=CrossReferences&$select=InventoryID&$filter=CrossReferences/VendorOrCustomer%20eq%20'V000000247'%20and%20CrossReferences/AlternateID%20eq%20'8836'", ResponseText) <> 0 Then

@FredL reviewing your query seems like you are trying to add a filter on a detail/child entity which is not currently supported. As a workaround, I would suggest creating a Generic Inquiry that has all the fields you need to work with and pull data in your API call using that GI. You could filter as required on GI.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved