(Solved) – How to use XMLHttpRequest using VBA with object data


I am currently trying to make a msgbox for a userform that I am making that responds with the data from the below javascript using VBA

                type: "GET",
                url: app.global.AppPath   'Dashboard/GetComments',
                async: false,
                data: {
                    id: 1015998
                success: function(result) {}

VBA Code:

Private Sub UserForm_Click()
    Dim strUrl As String
        strUrl = "https://charter.osp-cloud.com/ATOM/Dashboard/GetComments"

    Set hReq = CreateObject("MSXML2.XMLHTTP")
        With hReq
            .Open "GET", strUrl, False
            .SetRequestHeader "Content-Type", "text/json"
            .Send "id=1015998"
        End With
    MsgBox hReq.ResponseText
End Sub

Does anyone know what I am doing wrong? Is it because I am not sending a object .Send "{id: 1015998}"?

upon a little more research I found that maybe parsejson might work but I cant seem to get it to recognize that there is an object

Dim JSON As Dictionary
Set JSON = JsonConverter.ParseJson("{""id"": 1015998}")

Error says “Object Required”

response pulled is below

The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult GetComments(Int32)' in 'EZTRACKER.Controllers.DashboardController'.

Leave a Reply

Your email address will not be published. Required fields are marked *