Hi Powerbuilder friends,
I have this code where I need to send data to our payment partner. It successfully requests a token, but no data is transferred, and there's an authorization error with the JWT token request.
String ls_jwttoken, ls_PostData,ls_P020_Responsebody, ls_error
Integer li_jwttoken_return, li__P020_SendReturn
Long ll_RootObject
JsonParser lnv_JsonParser
RestClient lrc_client
TokenResponse response
lrc_client = Create RestClient
lnv_JsonParser = Create JsonParser
response = Message.powerobjectparm
lrc_client.SetRequestHeaders( "Content-Type: application/x-www-form-urlencoded" )
//Gets the JWT token. The second parameter provides the value according to the token server request.
li_jwttoken_return=lrc_client.GetJWTToken("https://authstage.enderrew.com/oauth2/token/", 'client_id=c2b82343432423bdc67f9&client_secret=85e95df535fd0842343432dc7f64bb5dee&grant_type=client_credentials', ls_jwttoken)
IF li_jwttoken_return = 1 THEN
//Sets the JWT token
lrc_client.SetJwtToken( ls_jwttoken)
lnv_JsonParser.LoadString(ls_jwttoken)
ll_RootObject = lnv_JsonParser.GetRootItem()
mle_accesstoken.Text = lnv_JsonParser.GetItemString(ll_RootObject, "access_token")
ls_PostData=dc_data.Exportjson()
li__P020_SendReturn =lrc_client.SendPostRequest("https://gshdsasj-stage-e6jg27ou7a-asss.ab.run.app/bills", ls_PostData, ls_P020_Responsebody)
IF li__P020_SendReturn <> 1 Or lrc_client.GetResponseStatusCode() <> 201 Then
ls_error = string(ls_P020_Responsebody)
END If
ELSE
MessageBox('Error',ls_jwttoken)
END IF