[Progress Communities] [Progress OpenEdge ABL] Forum Post: Webservice Method Rest

Status
Not open for further replies.
W

wsartorelli

Guest
Hello people. I'm trying to make a Webservices consumption program with the REST method, but I'm having a runtime error. Can someone help me with this code? Follow my code. Thank you. block-level on error undo, throw. using OpenEdge.Core.String. using OpenEdge.Net.HTTP.ClientBuilder. using OpenEdge.Net.HTTP.IHttpClient. using OpenEdge.Net.HTTP.IHttpRequest. using OpenEdge.Net.HTTP.RequestBuilder. using OpenEdge.Net.HTTP.IHttpResponse. /* *************************** Definitions ************************** */ define variable httpClient as IHttpClient no-undo. define variable emptyReq as IHttpRequest no-undo. define variable resp as IHttpResponse no-undo. DEF VAR apiID AS CHAR NO-UNDO. DEF VAR apiSecret AS CHAR NO-UNDO. DEF VAR httpmethod AS CHAR NO-UNDO. DEF VAR apikey AS CHAR NO-UNDO. DEF VAR httpurl AS CHAR NO-UNDO. DEF VAR dat_ref AS CHAR NO-UNDO. DEF VAR stringtosign AS CHAR NO-UNDO. DEF VAR secretKey AS MEMPTR NO-UNDO. DEF VAR c_signature AS LONGCHAR NO-UNDO. DEF VAR x-cod-date AS CHAR NO-UNDO. ASSIGN apiid = "xmbfouiauy5d" apisecret = "sxOzKUd3XX6Vc/dAiUvO0retebjOhXI/k6Qjb4JTLggnwIxfTekdvm/pRjC+iTpZB5wOcOsZWZWGVdg+k0uTaA==". ASSIGN dat_ref = 'x-csod-date:' + STRING(YEAR(TODAY),"9999") + "-" + STRING(MONTH(TODAY),"99") + '-' + STRING(DAY(TODAY),"99") + "T" + STRING(TIME,"HH:MM:SS") + ".000" x-cod-date = STRING(YEAR(TODAY),"9999") + "-" + STRING(MONTH(TODAY),"99") + '-' + STRING(DAY(TODAY),"99") + "T" + STRING(TIME,"HH:MM:SS") + ".000". ASSIGN httpMethod = 'POST' apiKey = 'x-csod-api-key:' + apiId httpUrl = '/services/api/sts/session'. stringToSign = httpMethod + "\n" + apiKey + "\n" + dat_ref + "\n" + httpUrl. ASSIGN secretKey = base64-DECODE(apiSecret). ASSIGN c_signature = base64-ENCODE(MESSAGE-DIGEST('SHA-512', stringToSign, secretKey)). /* *************************** Main Block *************************** */ httpClient = ClientBuilder:Build():Client. emptyReq = RequestBuilder:post(' ype-stg.csod.com/.../session , String:Empty()) :AddHeader("Content-Type", "text/xml") :AddHeader("x-cod-api", apiid) :AddHeader("x-cod-date", x-cod-date) :AddHeader("x-cod-signature", string(c_signature)) :Request. resp = httpClient:Execute(emptyReq). catch e as Progress.Lang.Error : message e:GetMessage(1) skip(2) e:CallStack view-as alert-box. end catch. Message Error: Answer that I should get: 201 2015-09-08T14:45:02+0000 1 1v28u30hyoxsn N1mxiOOtzc4BBg7XIX2ROc0aN0d0J6vVy6U02CC+DWZl4GuUNEbMtRmVlP7Sb/+9u12RJM+58YphBIsoOldubA== soapadmin1 2015-09-08T14:45:02+0000

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