1. Ashutosh Varshney
  2. PowerBuilder
  3. Thursday, 10 March 2022 21:57 PM UTC

Hello Folks,

I am trying to call a REST webservice from my PowerBuilder 2021 application. I have been provided with a URL and a userid/password to authenticate. I am following our friend Bruce's REST tutorial. I created an external DW with one column and assigned it to dw_1. Here is my code:

String ls_URL, ls_mess

Integer li_rtn

RESTClient rest

 ls_URL = 'http://my-url.cloud:7780'

rest = Create RESTClient

rest.Retrieve (dw_1, ls_URL)

li_rtn = rest.GetResponseStatusCode ()

ls_mess = rest.GetResponseStatusText ()

Messagebox ('REST', 'Code: ' + String (li_rtn) + '~r~n' + ls_mess)

 

I get 401 - Not Authorized. How do I pass the userid/password to the webservice ?

 

Thank You

 

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 10 March 2022 22:44 PM UTC
  2. PowerBuilder
  3. # Permalink
Comment
  1. Chris Pollach @Appeon
  2. Friday, 11 March 2022 19:40 PM UTC
If this is a true RESTFul web service, then the arguments would probably require a JSON data stream. For example ...

String ls_jason = '{"empId":101, "fname":" John", "lname": "Guevara"}'

li_rc = HttpClient.SendRequest ( "POST", " https://<url>/<method";, ls_json )
  1. Helpful
  1. Ashutosh Varshney
  2. Friday, 11 March 2022 21:04 PM UTC
That was it! Thanks Chris.



ls_URL = 'http://my-url.cloud:7780/api/getOrder'

ls_strIN = '"orderID":"test123"'

li_rc = lhc_Client.SendPostRequest (ls_URL, ls_strIN, ls_Response)
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 11 March 2022 21:13 PM UTC
Awesome ... super glad that it's now working for you! :-)
  1. Helpful
There are no comments made yet.
Ashutosh Varshney Accepted Answer Pending Moderation
  1. Friday, 11 March 2022 14:08 PM UTC
  2. PowerBuilder
  3. # 1

Thanks Chris. 

Comment
  1. Chris Pollach @Appeon
  2. Friday, 11 March 2022 15:37 PM UTC
You are most welcome ... HTH!
  1. Helpful
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.