Hello,
I have the following VBA code which passes a POST request. When tested in the debugger, the API works fine, but for some reason the VBA does not return the response into the cell as it is supposed to. What I would like it to do is pass the content of cell F3 to the API, and return the response to Cell G3, F4 to G4, etc. Appreciate any help!
I have the following VBA code which passes a POST request. When tested in the debugger, the API works fine, but for some reason the VBA does not return the response into the cell as it is supposed to. What I would like it to do is pass the content of cell F3 to the API, and return the response to Cell G3, F4 to G4, etc. Appreciate any help!
VBA Code:
Public Sub XMLhttp_NLP()
On Error Resume Next
Dim Content As Long
Dim Strresponse As Long
Dim i As Long
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
Dim Sheet As Worksheet
Set Sheet = Sheets(Sheet1)
For i = 3 To FinalRow
Content = Range("F" & i)
Const APIkey = "pretendapikey12345"
Dim httpReq As Object
Set httpReq = CreateObject("MSXML2.XMLHTTP")
Dim rootURL As String, registrationEndpointURL As String
Dim registration As String
Dim text As String
text = Content
rootURL = "https://api.service.com/"
With httpReq
.Open "POST", rootURL, False
.setRequestHeader "text=", text
.setRequestHeader "x-textrazor-key:", APIkey
.send ("extractors=entities,entailments&text=" & text)
.responseText = Strresponse
ThisWorkbook.Worksheets("Sheet1").Range("G" & i).Value = Strresponse
End With
Next i
End Sub