PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → httpsend
httpsend
Iniciado por kel, 05,nov. 2020 22:01 - 3 respuestas
Publicado el 05,noviembre 2020 - 22:01
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
Miembro registrado
54 mensajes
Popularité : +2 (2 votes)
Publicado el 06,noviembre 2020 - 10:35
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
Publicado el 09,noviembre 2020 - 00:10
Works great thanks for the help
Publicado el 10,enero 2021 - 13:20
Hi Andrea Chiadò Piat:
Can the HTTPAddParameter pass array value?