1. Sivaprakash BKR
  2. PowerBuilder
  3. Saturday, 6 April 2024 05:58 AM UTC

Hello,

Using PB 2022 R3

Need to call an API, parameter in key-value pair.   How to pass the same in Powerbuilder?

<?php

  $create = [
      "secret" => "API_SECRET", // your API secret from (Tools -> API Keys) page
  ];

  $cURL = curl_init("https://app.bulkwise.in/api/create/wa.link");
  curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($cURL, CURLOPT_POSTFIELDS, $create);
  $response = curl_exec($cURL);
  curl_close($cURL);

  $result = json_decode($response, true);

  // do something with response
  print_r($result);

The above is the code that's working in PHP.   

Now need to make it to work in Powerbuilder also.    See the parameter $create, it's a key-value pair.   

How to pass these value, if we need to use HTTPClient in PB?   Any idea, workaround, solution?

Happiness Always
BKR Sivaprakash

 

Accepted Answer
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Saturday, 6 April 2024 13:36 PM UTC
  2. PowerBuilder
  3. # Permalink

Sorry for troubling you.

Got it solved.  I need to pass the parameters as a part of URL.  

https://app.bulkwise.in/api/create/wa.link?secret=something

Solved the issue.

Happiness Always
BKR Sivaprakash

 

Comment
  1. Benjamin Gaesslein
  2. Monday, 8 April 2024 08:35 AM UTC
I don't think it's a good idea to use a GET to send secrets to an API, this is not secure. You should definitely use the POST method instead. See Example 2 here:



https://docs.appeon.com/pb2019/powerscript_reference/ch10s586.html
  1. Helpful 1
  1. Sivaprakash BKR
  2. Monday, 8 April 2024 08:53 AM UTC
Yes, I agree. But the API provider has done like that. I've already made a note about this to them. Let's see what they reply.
  1. Helpful 1
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from 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.