Help on execute curl command in peoplecode
I am trying to make a curl command call in my people code like below - this is a get API call to the vendor to get the access-token (or called bearer) back through a Oauth2 authentication scheme:
Declare Function ExecutecURLCommand PeopleCode UM_FUNCLIB_RCT.DESCR FieldFormula;
Local string &strURL = "curl -X GET -H ""Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"" -H ""customer-id: 100000"" -H ""trading-partner: xxxxxxx"" https://sample.com/v2/oauth";
Local string &strResponse = ExecutecURLCommand(&strURL);
I have the function defined below -
Function ExecutecURLCommand(&cURLCommand) Returns string
Local JavaObject &runtime = GetJavaClass("java.lang.Runtime").getRuntime();
Local JavaObject &process = &runtime.exec(&cURLCommand);
Local JavaObject &inputStreamReader = CreateJavaObject("java.io.InputStreamReader", &process.getInputStream());