Skip to main content
Answer

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

  • October 9, 2023
  • 2 replies
  • 451 views

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!

Best answer by RohitRattan88

 
   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.

2 replies

Forum|alt.badge.img+8
  • Semi-Pro I
  • October 13, 2023

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


RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+4
  • Acumatica Moderator
  • Answer
  • October 17, 2023

 
   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.