Jump to content

Examples of logging requests (with workflows) via API


Recommended Posts

Hello,

Just wondering if anyone has any script examples of logging a request that has an attached workflow via the API.

I'm trying to make API requests to log a ticket in the same way a user would, providing answers to questions that are asked in the Intelligent Capture. The documentation is good at telling me which fields need to be provided, but I can't figure out how to format some of the parameters to make sure a workflow is attached to the request and that the answers are passed.

Thank you

Link to comment
Share on other sites

11 minutes ago, Mark Burns said:

logging a request that has an attached workflow via the API

How is that request raised, what API are you using specifically and what would be an example payload? For example, are you using the generic logRequest or the request type ones, such as logIncident?

Link to comment
Share on other sites

We've recently gone live with an automated process to raise requests. Yes, working out the required fields on the JSON objects took a little bit of trial and error!

I seem to recall the "questions" and  "questionFieldMap" parameters giving me the most issue, so hopefully this is of use!

The "questions" parameter wants the JSON to look something like this (or at least, this is what worked for me!):

[
    {
        "form_id":  "form_id",
        "question":  "Question 1",
        "question_id":  "h_custom_a",
        "answer":  "Answer",
        "answer_value":  "Answer value",
        "field_type":  "text",
        "entity_type":  "request"
    },
    {
        "form_id":  "form_id",
        "question":  "Question 2",
        "question_id":  "h_custom_b",
        "answer":  "Answer 2",
        "answer_value":  "Answer 2 Value",
        "field_type":  "text",
        "entity_type":  "request"
    }
]

The "questionFieldMap" parameter (assuming you want to map custom fields on the request being raised) wants an answer like this:

{
    "h_custom_a":  "Answer",
    "h_custom_b":  "Answer 2"
}

Common field types are defined as: checkboxlist, datetimepicker, queryselect (e.g. user lookup), radioset, text, textarea (i.e. multi line text fields)

Hope that helps!

Link to comment
Share on other sites

3 minutes ago, CraigP said:

The "questions" parameter wants the JSON to look something like this (or at least, this is what worked for me!)

Just to be aware, we don't have this part of the API documented just yet so officially it is not yet supported (this part). If it works now, great, but it can be subject to change without prior notice.

Link to comment
Share on other sites

2 hours ago, CraigP said:

The "questions" parameter wants the JSON to look something like this (or at least, this is what worked for me!):

Fantastic, thank you! That's got the questions section of ticket logging sorted.

 

2 hours ago, Victor said:

are you using the generic logRequest or the request type ones, such as logIncident?

I'm currently using the generic request. I'd like to use the specific request type ones, but not sure how to format the request for that. the documentation states this example:

Quote

(E.g. For Incidents, use Incidents::fc_ops::logIncident operation).

It's a service request I'm trying to create - how would I use the specific request types with the API?

Cheers

Link to comment
Share on other sites

Thank you @Victor, that's got me in the right direction.

I'm still struggling with creating a ticket with a workflow attached. I've put the correct Service ID in and that shows up on the request, however, no workflow seems to be attached (I can't see the workflow being processed along the top of the request page).

Is there a way to see if a workflow has been attached to a request besides seeing the green process bar at the top?

Cheers

image.png

Link to comment
Share on other sites

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
×
×
  • Create New...