Jump to content

Feeding PCF answers to request via API


Recommended Posts

Hi all,

 

I'm trying to dynamically kick off change requests using the Hornbill api and using the logChangeRequest method, but in order for it to be logged correctly and the BPM to kick in I also need to feed it the expected answers from a progressive capture form. I've tried answering the questions using their field id within the "questions" param, however no matter which way I try to format them I get a FlowCode exception.

I'm making the call within a PoSh script and have successfully logged Service Requests/Incidents, just this is currently giving me grief!

 

Example params:

$xmlmcParams = "
<summary>$summary</summary>
<description>$description</description>
<requestType>Change Request</requestType>
<teamId>STB/IT_#####/IT_#####/</teamId>
<status>status.new</status>
<sourceType>API</sourceType>
<questions>
  <Question_1>Standard</Question_1>
  <Question_2>Low</Question_2>
  <Question_3>Standard process</Question_3>
  <Question_4>Low</Question_4>
  <Question_5>Standard process</Question_5>
  <Question_6>Roll back</Question_6>
  <Question_7>n/a</Question_7>
</questions>
<changeType>Standard</changeType>"

Exception:

FlowCode Exception (com.hornbill.servicemanager/entities/ChangeRequests/fc_ops/logChangeRequest): Input parameter validation error: The simple type value contains unexpected child elements at location &apos;/methodCall/params/questions&apos;

Do I also need to supply the questionFieldMap param for this to work?

 

If anyone has a working example of making a call which contains answers which would normally be fed from a prog capture that would be b e a u tiful.

 

 

 
Link to comment
Share on other sites

Hi @Chris Bayliss,

The questions input parameter isn't complex XML, it actually expects a JSON string with the question data in. You also need to populate the questionFieldMap input parameter too, if you're wanting to write anwers to additional request fields. 

The best advice I can give here is for you to run through the progressive capture with your browser developer tools open, and on the network tab filter by the name of the flowcode you're calling. Once the change has been logged, you'll be able to see the API call that was made, and its payload, so you can copy the JSON out of both parameters and paste in to your script. Here's one for an incident I've just logged, that populates the questions and questionFieldMap parameters. 

spacer.pngimage.png

Just to note, too. I notice that you're building the XML for your API call manually in the script. We've actually released a Powershell module containing cmdlets that will make the building and sending of Hornbill API calls much easier. It's on the Powershell Gallery for you to install: https://www.powershellgallery.com/packages/HornbillAPI/1.1.0

Once you've got that, then you can build and make your API calls as so: 

# Define instance details
Set-HB-Instance -Instance "yourinstanceid" -Key "yourapikey"

# Build API Call
Add-HB-Param "summary" "Whatever you want to put in the summary" $false
Add-HB-Param "description" "Whatever you want to put in the description" $false

# Invoke XMLMC call, output returned as PSObject
$xmlmcOutput = Invoke-HB-XMLMC "apps/com.hornbill.servicemanager/Incidents" "logIncident"

Let me know how you get on with this.

Cheers!

Steve

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • Victor changed the title to Feeding PCF answers to request via API

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...