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!