I am new to working with the REST api. I have successfully created some VBA code within an excel spreadsheet that queries one of my BAQs. I pass in the parameters and the return string gives me exactly what I want.
I then attempt to call a different BAQ, again passing parameters. I get nothing back. I have verified my url string using the REST help on the server. I have tried declaring a second object but that does not help either.
Is there something I am missing making the second call? Here is my code:
Function Fill_Part_Data()
Dim objRequest As Object, objRequest2 As Object
Dim strUrl As String
Dim blnAsync As Boolean
Dim strResponse As String
Dim strParentRev As String, strRevDate As String, strContract As String, strAuthDoc As String, strPartNum As String
Dim strPartList As String, strDrawing As String, strRev As String, strTitle As String
Dim intPos As Integer, intPos2 As Integer
Dim strTemp As String, strDate As String, strESD As String
strPartNum = "272A001100-01"
strRev = "-"
Set objRequest = CreateObject("MSXML2.XMLHTTP")
blnAsync = True
strUrl = "https://server/EpicorERPTest/api/v1/BaqSvc/ASI_DataList_Parent/?PartNumber='" & strPartNum & "'&Rev='" & strRev & "'"
With objRequest
.Open "GET", strUrl, blnAsync
.SetRequestHeader "Content-Type", "application/json"
.Send
'spin wheels whilst waiting for response
While objRequest.readyState <> 4
DoEvents
Wend
strResponse = .ResponseText
End With
Debug.Print strResponse
'parse apart the header data
...
'now go get the detail data
Set objRequest = Nothing
Set objRequest2 = CreateObject("MSXML2.XMLHTTP")
strUrl = "https://server/EpicorERPTest/api/v1/BaqSvc/ASI_IBOM_PartList/?BOM='" & strPartNum & "'&Revision='" & strRev & "'"
With objRequest2
.Open "GET", strUrl, blnAsync
.SetRequestHeader "Content-Type", "application/json"
.Send
'spin wheels whilst waiting for response
While objRequest2.readyState <> 4
DoEvents
Wend
strResponse = .ResponseText
Debug.Print strResponse
End With
End Function