1. John Michael Tejano
  2. PowerBuilder
  3. Thursday, 25 July 2024 03:29 AM UTC

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























René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 25 July 2024 04:49 AM UTC
  2. PowerBuilder
  3. # 1

You have to check all request details. Is it really correct to use Content-Type application/x-www-form-urlencoded? Usually is application/json if you send json data.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.