1

Im calling PostJsontext with a valid url and a valid APIkey (Username). Posting the jsontext results in 'invalid parameter' message in the line : .send(Jsontext)

Using the same routine with: .Open("GET", Xurlget, False, StrUsername, "") .send() results in a valid .responsetext.

No idea where to go or what to do on order to post the data of all. Why will that line producing an error an how can it be fixed?

Public Sub PostJsonText(ByVal xurl As String, ByVal Xurlget As String, ByVal StrUsername As String, ByVal StrPassword As String, ByRef xJsonText As String, ByRef OkAuthenticateCredentials As Boolean, ByRef Credstatus As Int32)

    Dim Jsonservice As Object = CreateObject("MSXML2.XMLHTTP.6.0")
    Dim Jsontext As String


    jsontext =
        "{""idvatgroup"":3996,""idsupplier"":111,""productcode"":""tester2"",""name"":""tester2"",""price"":22,""fixedstockprice"":22,""productcode_supplier"":""22""}"


    With Jsonservice
        .Open("POST", Xurlget, False, StrUsername, "")

        .setRequestHeader("Content-Type", "application/json")
        .setRequestHeader("Accept", "application/json")

       .setRequestHeader("Authorization", "Basic " & StrUsername)
       .send(jsontext)

        Credstatus = .Status
        If .Status <> 401 Then
            jsontext = .Responsetext
            OkAuthenticateCredentials = True
        Else
            OkAuthenticateCredentials = False
            JsonText = "Error: Invalid Credentials!"
        End If
    End With
    Jsonservice = Nothing
Tim Williams
  • 154,628
  • 8
  • 97
  • 125
henktmu
  • 11
  • 2

0 Answers0