Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPS API - Landed Cost

Swi

Programmer
Feb 4, 2002
1,967
US
Hi,

I was doing some testing and it seems everything is connection fine however I keep getting an 400 error that says Unable to validate HS code(s).

I have used their sample on UPS but having no luck. Any ideas? Thanks.

https://developer.ups.com/tag/Landed-Cost?loc=en_DK&tag=Landed-Cost

Code:
    strClientId = "xxxxxxxxxxxxxxxxxxxxxx"
    strClientSecret = "yyyyyyyyyyyyyyyyyyyy"
    strHead = strClientId & ":" & strClientSecret
    url = "https://wwwcie.ups.com/security/v1/oauth/token"
    Set HTTPReq = New MSXML2.ServerXMLHTTP60
    HTTPReq.Open "POST", url, False
    HTTPReq.setRequestHeader "Authorization", "Basic " + EncodeBase64(strHead)
    HTTPReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    HTTPReq.setRequestHeader "x-merchant-id", "99999999999"
    HTTPReq.send "grant_type=client_credentials"
    Set myJSON = JSON.parse(HTTPReq.responseText)
    token = "Bearer " & myJSON.Item("access_token")
    Set HTTPReq = Nothing
    
    url = "https://wwwcie.ups.com/api/landedcost/v1/quotes"
    Set HTTPReq = New MSXML2.ServerXMLHTTP60
    HTTPReq.Open "POST", url, False
    HTTPReq.setRequestHeader "AccountNumber", "9999999"
    HTTPReq.setRequestHeader "Authorization", token
    HTTPReq.setRequestHeader "Content-Type", "application/json"
    HTTPReq.setRequestHeader "transId", "999999999"
    HTTPReq.setRequestHeader "transactionSrc", "LandedCost"
    Set InStream = fso.OpenTextFile("C:\Test.txt", ForReading)
    JSONText = InStream.ReadAll
    HTTPReq.send JSONText
    MsgBox HTTPReq.responseText
 

Part and Inventory Search

Sponsor

Back
Top