I want to retrieve some data from an API using an GET request. The API takes one parameter encoded as JSON in the body of the request. The following code works fine for sending a POST request with some JSON data however if the type of the request is changed to GET the final request being sent contains no body:
Dim strJSONText As String, strURL As String
strURL = "https://<domain>/<some>/<path>"
strJSONText = "{'<parameter>':'<value>'}"
Set objXMLhttp = CreateObject("Msxml2.XMLHTTP")
objXMLhttp.Open "GET", strURL, False
objXMLhttp.setRequestHeader "Accept", "application/json"
objXMLhttp.setRequestHeader "Content-Type", "application/json"
objXMLhttp.send (strJSONText)
Why is strJSONText
being ignored whenever the request type is GET? How do I send a GET request with a body using VBA?