I'm trying to obtain an API key via an HTTPrequest (POST).
I'm using the “TEST server” data they provided.
Their website API instructions are at :
https://developer.estes-express.com/...kyNzc.#API-Key
The example provided by the API folks is:Test example only:
Basically it says if you send in the client-id and client-secret in the header the response will return the API key.Code:curl -X POST 'https://uat-cloudapi.estes-express.com/v1/api-key' -H 'accept: application/json' -u ClientID:ClientSecret {redacted}'
I keep getting an error "401 Not Authorized” .
My code is below. am I missing something?
thanks
-dan
Code:Dim clientid As String = ("{redacted}") Dim clientsecret As String = ("{redacted}") Dim response As HttpWebResponse = Nothing Dim request As HttpWebRequest = CType(WebRequest.Create("https://uat-cloudapi.estes-express.com/v1/api-key"), HttpWebRequest) request.Method = ("POST") request.Accept = "application/json" request.Headers.Add(clientid, clientsecret) Try Dim httpResponse As System.Net.HttpWebResponse = CType(request.GetResponse(), HttpWebResponse) Dim sr As System.IO.StreamReader = New System.IO.StreamReader(httpResponse.GetResponseStream()) sr.Close() Catch ex As WebException Dim errmsg As String = ex.Message If ex.Response IsNot Nothing Then Dim httpResponse As HttpWebResponse = DirectCast(ex.Response, HttpWebResponse) Console.WriteLine($"HTTP Error: {httpResponse.StatusCode} - {httpResponse.StatusDescription}") End If End Try




Reply With Quote
