UPS new OAuth QVEvent POST API into VBA

25 views Asked by At

need some help finishing the POST API for the new oauth authorization API for UPS. I got the TRACKING event done, that one was simpler than the QVEvent. I have the HEADER request complete. After that the "-d" part is missing in my code. I have posted the curl request from the UPS site under my code.

Sub GET_Tracking1()
    Dim strHead As String, strClientId As String, strClientSecret As String
    Dim strFile_Path As String
    strClientToken = access_token
    With CreateObject("MSXML2.ServerXMLHTTP")
        .Open "POST", "https://wwwcie.ups.com/api/quantumview/v1/events"
        .setRequestHeader "Authorization", "Bearer " + strClientToken
        .setRequestHeader "Content-Type", "application/json"
        ................
        ................
        .send
        Debug.Print .responseText
        strFile_Path = "C:\test.JSON"
        Open strFile_Path For Output As #1
        Print #1, .responseText
        Close #1
    End With
End Sub

Need to represent....

  curl -i -X POST \
  https://wwwcie.ups.com/api/quantumview/v1/events \
  -H 'Authorization: Bearer .......' \
  -H 'Content-Type: application/json' \
  -d '{
    "QuantumViewRequest": {
      "Request": {
        "TransactionReference": {
          "CustomerContext": "",
          "XpciVersion": "1.0007"
        },
        "RequestAction": "QVEvents"
      },
      "SubscriptionRequest": {
        "FileName": "220104_140019001",
        "Name": "OutboundXML",
        "Bookmark": "WE9MVFFBMQ=="
      }
    }
  }'
1

There are 1 answers

1
Ron2020 On

thank you @TimWilliams, added string of BODY and used the ".Send Body" to submit.