[Progress Communities] [Progress OpenEdge ABL] Forum Post: POST TOKEN

  • Thread starter Giancarlo Alberto Somma
  • Start date
Status
Not open for further replies.
G

Giancarlo Alberto Somma

Guest
Hi, I have to GET a TOKEN, Follow the parameters requested. Link to request token http://sage.brusapiastrelle.ch/ token Parameter to set headers Content-Type application/x-www-form-urlencoded Parameter to set body username sage password ${>P3c72p=fyT5ZH grant_type password. Its seems the code below is not correct (404 Not Found). Can you help Me? Thanks a lot. BLOCK-LEVEL ON ERROR UNDO, THROW. USING OpenEdge.Core.String. USING OpenEdge.Net.HTTP.ClientBuilder. USING OpenEdge.Net.HTTP.IHttpRequest. USING OpenEdge.Net.HTTP.IHttpResponse. USING OpenEdge.Net.HTTP.RequestBuilder. USING Progress.Json.ObjectModel.JsonObject. DEFINE VARIABLE httpUrl AS CHARACTER NO-UNDO. DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO. DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO. DEFINE VARIABLE oRequestBody AS String NO-UNDO. DEFINE VARIABLE oJsonEntity AS JsonObject NO-UNDO. DEFINE VARIABLE JsonString AS LONGCHAR NO-UNDO. SESSION:DEBUG-ALERT = TRUE. httpUrl = " sage.brusapiastrelle.ch/token". oRequestBody = new String('username=sage&password=$~{>P3c72p=fyT5ZH&grant_type=password'). oRequest = RequestBuilder:post(" sage.brusapiastrelle.ch/token" , oRequestBody) :ContentType('application/x-www-form-urlencoded') :AcceptJson() :Request. oResponse = ClientBuilder:Build():Client:Execute(oRequest). MESSAGE oResponse:StatusCode SKIP oResponse:StatusReason SKIP VIEW-AS ALERT-BOX. oJsonEntity = CAST(oResponse:Entity, JsonObject). oJsonEntity:Write(JsonString, TRUE). MESSAGE STRING(JsonString) VIEW-AS ALERT-BOX.

Continue reading...
 
Status
Not open for further replies.
Top