1. Brett Weaver
  2. PowerBuilder
  3. Monday, 3 July 2023 04:03 AM UTC

Hi Folk

Sorry to ask what is a basic question, but I have never connected to RESTful Web services before.

Soap was the only protocol I have used and that was some time ago.

I need an example and instructions that relate to PB2022.

I have heard that Bruce has written an article but I can't seem to find it. Maybe if someone has the link?

Examples I have found use OLE and I'm pretty sure I shouldn't have to use that.

Cheers

Brett Weaver

Brett Weaver Accepted Answer Pending Moderation
  1. Monday, 3 July 2023 19:17 PM UTC
  2. PowerBuilder
  3. # 1

Thanks for everyone's help, I appreciate it. I just was wading through information supplied by third party vendors and stuff that seemed old. 

I didn't want to use a method that was not the right way going forward.

 

Again - what a great bunch of people you all are thanks so much!

 

Comment
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Monday, 3 July 2023 13:10 PM UTC
  2. PowerBuilder
  3. # 2

Brett,

Assuming that you have your server-side works are over.   And depending on the language you used in server-side [ C# through Snapdevelop or other scripting languages like PHP or others ], you may need to learn about RESTClient or HTTPClient.

Here is a sample code to access a webservice using HTTPClient.   We have used PHP with Slim Framework on server side and use JSON to transfer data.  

lo_client = Create HTTPClient
lo_client.SetRequestHeader("Accept", "*/*")
lo_client.SetRequestHeader('Content-Type','application/json') 

String   ls_json
ls_json = '%Substitute Some JSON values%'
ls_api = 'http://localhost/stock/country/insert'

li_ret = lo_client.SendRequest('Post', ls_api, ls_json)
If li_ret = 1 Then
   li_statuscode = lo_client.GetResponseStatusCode()
   If li_statuscode = 200 or li_statuscode = 201 Then
      lo_client.GetResponseBody(ls_body)
      If IsNull(ls_body) = False and Trim(ls_body) <> '' Then
         ls_return_json = ls_body
      Else
         ls_return_json = ''
      End If
   Else
      lo_client.GetResponseBody(ls_error)
      Messagebox('Error', ls_error)
   End If
Else
   lo_client.GetResponseBody(ls_error)
   Messagebox('Connection Error', 'Could not connect to WebServer. ' + &
				  'Check your internet connection. ' + &
				  'Check Whether Webserver is running.~r~n' + ls_error
End If

 

One Simple code snippet.

HTH

Happiness Always
BKR Sivaprakash

 

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 3 July 2023 11:50 AM UTC
  2. PowerBuilder
  3. # 3
Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 3 July 2023 05:22 AM UTC
  2. PowerBuilder
  3. # 4
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.