none
Can you please help me to get the excel VBA code for this API call RRS feed

  • Question

  • curl -X POST -H 'Accept: application/vnd.softix.api-v1.0+json' -H 'Accept-Language: en_US' -u 'CLIENTID:SECRET' -d
    'grant_type=client_credentials' https://api.etixdubai.com/oauth2/accesstoken -v

    I have below code - which gives me an error

    *------------------------------------------------------------*
      Dim webServiceURL As String
      Dim actionType As String
      Dim targetWord As String
      Dim actionType2 As String
      Dim targetWord2 As String
      
      webServiceURL = "https://api.etixdubai.com/oauth2/accesstoken"
      actionType = "Accept"
      targetWord = "application/vnd.softix.api-v1.0+json"
      actionType2 = "Accept-Language"
      targetWord2 = "en_US"
      
    ' use late binding
      With CreateObject("Microsoft.XMLHTTP")
        .Open "POST", webServiceURL, False
        .SetRequestHeader actionType, targetWord
        .SetRequestHeader actionType2, targetWord2
       
       .SetCredentials "b88e63551fd048748c11f1f72773ee12", "c378c3b28ef64a72ad7040cc8db7a169"
        .Send
        If .Status = 200 Then
          Debug.Print .ResponseText
          MsgBox .GetAllResponseHeaders
        Else
          MsgBox .Status & ": " & .StatusText
        End If
      End With

    *---------------------------------------------*

    Saturday, December 16, 2017 3:25 AM

All replies

  • Try the code below.

    Andreas.

    Sub Test()
      Dim webServiceURL As String
      Dim actionType As String
      Dim targetWord As String
      Dim actionType2 As String
      Dim targetWord2 As String
    
      webServiceURL = "https://api.etixdubai.com/oauth2/accesstoken"
      actionType = "Accept"
      targetWord = "application/vnd.softix.api-v1.0+json"
      actionType2 = "Accept-Language"
      targetWord2 = "en_US"
    
      ' use late binding
      Dim XML As Object 'MSXML2.ServerXMLHTTP60
      'Set XML = CreateObject("Microsoft.XMLHTTP")
      Set XML = CreateObject("MSXML2.ServerXMLHTTP")
      With XML
        .Open "POST", webServiceURL, False
        .SetRequestHeader actionType, targetWord
        .SetRequestHeader actionType2, targetWord2
    
        .setProxyCredentials "b88e63551fd048748c11f1f72773ee12", "c378c3b28ef64a72ad7040cc8db7a169"
        .Send
        If .Status = 200 Then
          Debug.Print .ResponseText
          MsgBox .GetAllResponseHeaders
        Else
          MsgBox .Status & ": " & .StatusText
        End If
      End With
    End Sub

    Saturday, December 16, 2017 7:54 AM