PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 2024 → httpsend
httpsend
Started by kel, Nov., 05 2020 10:01 PM - 3 replies
Posted on November, 05 2020 - 10:01 PM
Hi I need to do the below

To retrieve an API Token
 Make a POST request to https://api.borderexpress.com.au/token with a header of: "Content-Type: application/x-www-form-urlencoded".
The entered request body should contain your URL encoded credentials in the format of:
grant_type=client_credentials&client_id={clientId}&client_secret={clientSecret}
If successful a result will be returned in JSON:
{ "access_token":"****", "token_type":"bearer", "expires_in":3599, "scope":"bex.webapi.basic", "userName":"username@borderexpress.com.au", ".issued":"Tue, 29 Aug 2017 05:45:16 GMT", ".expires":"Tue, 29 Aug 2017 06:45:16 GMT" }
For setup and testing purposes please connect to our test API https://integrationapi.borderexpress.com.au.
In order to request access to our API please email integrations@borderexpress.com.au and provide an email address to link to your API account.
After testing is complete and you are ready to deploy to live, please utilise our production API https://api.borderexpress.com.au


and my code is

myrequest is httpRequest
myrequest..Method = httpPost
myrequest..Header["Authorisation"] = "client_id=ec24ff28.880f.4dfd.8c70.03c7ba8a6030"
myrequest..ContentType = "application/x-www-form-urlencoded"
myrequest..URL = "https://api.borderexpress.com.au/token" //grant_type=client_credentials&client_id=ec24ff28.880f.4dfd.8c70.03c7ba8a6030&client_secret=vC/I+KA7dbTkiEN703sk6qy20qHScQ35 "
tempstring is string = "grant_type=client_credentials&client_id=ec24ff28.880f.4dfd.8c70.03c7ba8a6030&client_secret=vC/I+KA7dbTkiEN703sk6qy20qHScQ35"
myrequest..Content = NoSpace(tempstring)

myresponse is httpResponse

myresponse = HTTPSend(myrequest)



RESULT True

I am doing something wrong it keeps returning an error
any help would be great
Registered member
54 messages
Popularité : +2 (2 votes)
Posted on November, 06 2020 - 10:35 AM
Hello Kel,
for another type of service token request I use this code, you can do some try on it:

oRequest is a httpRequest
oResponse is a httpResponse

oRequest..URL = "https://auth.someservice.somesite.it/auth/signin"
oRequest..Method = httpPost

oRequest..User = ""
oRequest..Password = ""

// Type of Form
oRequest..ContentType = "application/x-www-form-urlencoded"
oRequest..Content = ""

// Form generation
HTTPCreateForm("FormData")
HTTPAddParameter("FormData", "grant_type", StringToUTF8("password"))
HTTPAddParameter("FormData", "username", StringToUTF8(YourUserName))
HTTPAddParameter("FormData", "password", StringToUTF8(YourPassword))

oRequest.IgnoreError=httpIgnoreInvalidCertificate

// Runs the request and retrieves the response
oResponse = HTTPSendForm("FormData", oRequest)

IF oResponse.StatusCode<>200 THEN
sMessErr="TokenError: "+oResponse..StatusCode+" - "+oResponse..DescriptionStatusCode+" - "+oResponse..Content+" - "+ErrorInfo()
ELSE
MyTokenAuth=JSONToVariant(oResponse..Content)
END

Hope this help
Bye

Andrea
Posted on November, 09 2020 - 12:10 AM
Works great thanks for the help
Posted on January, 10 2021 - 1:20 PM
Hi Andrea Chiadò Piat:
Can the HTTPAddParameter pass array value?