[Progress Communities] [Progress OpenEdge ABL] Forum Post: RE: Using NameValueCollection and webClient

Status
Not open for further replies.
P

Peter Judge

Guest
I've created an ABL equivalent using the HTTP client. It's at PeterJudge-PSC/http_samples The meat of it is below (minus variable defs and usings) assign hc = ClientBuilder:Build():Client // the first param is a realm you can leave blank creds = new Credentials('':u, clientId, clientSecret) . // build the request req = RequestBuilder:post(tokenEndpoint, // prior to 11.7.3 you had to pass in a valid object here. in 11.7.3+ you can not new StringStringMap() ) :AddFormData('client_id', 'oidc_ovf_conf') :AddFormData('grant_type','authorization_code') :UsingBasicAuthentication(creds) :Request. // make the request resp = hc:Execute(req). // process the response message resp:StatusCode skip // 200 is all went well resp:ContentType skip // something like application/json or application/x-www-form-urlencoded resp:ContentLength skip // number of bytes, if you care view-as alert-box. // this Entity property is DEFINED as Progress.Lang.Object // but the actual class/type will be something else; typically something that matches the ContentType // now get the response data in a nice, strongly-typed Object form // We can either decide what to do based on the ContentType or on the object's type // approach 1 case resp:ContentType: when 'application/json':u then assign jsonData = cast(resp:Entity, JsonObject). // other types end case.

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