Hi All
Hoping someone can assist me here. We have companies in separate servers where I need to trigger a Function in Company B from a BPM in Company A. I am doing this through Rest API and I can successfully trigger the Function. However, the input parameter to the Function is not being read.
The function accepts dsObject (Type String) as input parameter which is a dataset converted to a string, the function currently just returns an out put parameter which is just reading the input parameter which currently comes through as null.
Code:
var client = new HttpClient();
var url = "https://ServerAddress/Environment/api/v2/efx/Company/Library/Function";
string username = "User";
string password = "Password";
var creds = $"{username}:{password}";
var credsBase64 = Convert.ToBase64String(Encoding.ASCII.GetBytes(creds));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credsBase64);
client.DefaultRequestHeaders.Add("X-API-Key", "a*******************************");
//Converting dataset - dsResults to string
string jsonString = JsonConvert.SerializeObject(dsResults, Formatting.Indented);
//Setting string equal to dsObject which is how the input parameter is set in the Function
var jsonBody = $"{{ \"dsObject\": \"{jsonString}\" }}
//Rest Call
var response = client.PostAsync(url, new StringContent(jsonBody, Encoding.UTF8, "application/json")).GetAwaiter().GetResult();
//Reading output:
if(response.StatusCode.ToString() == "OK")
{
this.PublishInfoMessage("Output: " + root["outputValue"].ToString() , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
}
Does anyone on know how I should be passing the body in the Rest call to be able to set it to the input parameter on the function?