1. mathews rutto
  2. PowerBuilder
  3. Monday, 3 February 2020 06:12 AM UTC
Hello, how can i consume Rest API given that i have to pass API key and header request. I want to retrieve the response in a datawindow. Thank you in advance.
Accepted Answer
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 3 February 2020 15:30 PM UTC
  2. PowerBuilder
  3. # Permalink

And when you get the response, use the DataWindow ImportJson method.

Comment
There are no comments made yet.
mathews rutto Accepted Answer Pending Moderation
  1. Monday, 3 February 2020 16:02 PM UTC
  2. PowerBuilder
  3. # 1

Thank you for that.

I have managed.

Comment
There are no comments made yet.
mathews rutto Accepted Answer Pending Moderation
  1. Monday, 3 February 2020 13:49 PM UTC
  2. PowerBuilder
  3. # 2
Thank you for your response,

Show me how to pass with an example.

String ls_data = "<<<< YOUR PAYLOAD HERE >>>>>"

Also how will i retrieve the response into datawindow. If have DW_1

 

Regards Mathews

Comment
There are no comments made yet.
mathews rutto Accepted Answer Pending Moderation
  1. Monday, 3 February 2020 13:46 PM UTC
  2. PowerBuilder
  3. # 3

Thank you,

Show me how to pass 

String ls_data = "<<<< YOUR PAYLOAD HERE >>>>>"

and example.

Also how will i retrieve the response into datawindow. If have DW_1

 

Regards Mathews

Comment
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Monday, 3 February 2020 12:26 PM UTC
  2. PowerBuilder
  3. # 4

Hi Mathews,
API KEY goes into the request header, see below code.
Best,
.m

 

HTTPClient http
http = CREATE HTTPClient
http.SetRequestHeader("Authorization","Bearer <<<<< API KEY GOES HERE >>>>>>")
http.SetRequestHeader("Accept","application/json")
http.SetRequestHeader("Content-Type","application/json")

String ls_data = "<<<< YOUR PAYLOAD HERE >>>>>"

If http.SendRequest("POST", "https://someserver.com/api/endpoint", ls_data) = 1 Then
  If http.GetResponseStatusCode() = 200 Then  // 202 if asynchronous
    // OK
  end if
end if

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.