Automic Workload Automation

 View Only
Expand all | Collapse all

AE REST API quirks

  • 1.  AE REST API quirks

    Posted Nov 18, 2022 04:20 PM
    Edited by Michael A. Lowry Nov 21, 2022 04:39 AM
    I'm working on implementing Dependencies between UC4 systems, and have decided to use the REST API to query the status of tasks in the remote (predecessor) UC4 system. I've noticed a couple of quirks with the GET /executions API.

    • The name parameter doesn't work with object names that contain the # character.
    • The status parameter accepts either a comma-delimited list (documented) or a range separated by a dash (undocumented). However, the two cannot be combined. So 1900-1999 works, but 1900-1999,1899 does not. Update: see below.

    I'm not sure what to do about the first obstacle. Using HTML entities to escape the # character does not appear to help.

    The latter limitation is particularly annoying, because I was hoping to be able to recreate in a prompt set most of the options one can specify in external dependencies. For Expected task status, I can display a combo box with exactly the same condition/state names as in the AWI, using an SQL query like this:

    ​​SELECT ZUTYP_STATUS FROM UC_ZUTYP
    WHERE ZUTYP_ISALIVE = 0
    ORDER BY ZUTYP_STATUS ASC

    Then I can fetch the ZUTYP_STATUSRANGE that corresponds to the user's choice. But it's not very useful if I can't reliably pass it to the executions REST API. The ANY_OK_OR_UNBLOCKED status - probably the one chosen most often - corresponds to status codes 1900-1999 and 1899.

    Is there a way around this other than expanding the ranges into comma-delimited lists?

    Update: As @Joel Wiesmann points out in the replies below, specifying a range like 1900-1999 causes the AE to respond as if the  status parameter had not been specified at all.
    ​​


  • 2.  RE: AE REST API quirks

    Posted Nov 19, 2022 10:17 AM
    Here's another quirk in the behavior of the GET /executions endpoint. I was re-running some tests from this morning, and getting different results. After a bit of trial and error, I learned the reason.

    There's an undocumented default value for the time_frame_from parameter. I didn't test it rigorously, but my assumption is that it defaults to 24 hours ago. So if you want to list executions older than a day, you must specify an earlier time_frame_from value explicitly.


  • 3.  RE: AE REST API quirks

    Posted Nov 21, 2022 01:49 AM
    Hi Michael

    I hope this doesn't get posted twice as it seems my first post has gone​ /dev/null.

    Hashtags have a special meaning in URLs. So if used as parameter value, they must be escaped with %23:
    https://api.x.com/ae/api/v1/9002/executions?name=JOBP%23DEMO => JOBP#DEMO

    This works for me on V21
    ​​

    ------------------------------
    ☎️ Swisscom Automation Engineer & 🧙 PE Membership Creator

    Automic Kurse, Tutorials, Tools und mehr auf:
    https://membership.philippelmer.com/
    Zwei Wochen kostenlos testen!
    ------------------------------



  • 4.  RE: AE REST API quirks

    Posted Nov 21, 2022 03:48 AM
    I'm using Postman for these tests, and Postman automatically escapes the # character in parameters. Still, I must have been doing something else wrong before, because now it works fine. Thanks.



  • 5.  RE: AE REST API quirks

    Posted Nov 21, 2022 01:57 AM
    I just had a look at your feedback regarding the undocumented status range feature. This does *not* work for me. As soon as I introduce a range status search, the status search criteria is disabled and does not apply at all.

    The comma separated status list however works.

    ------------------------------
    ☎️ Swisscom Automation Engineer & 🧙 PE Membership Creator

    Automic Kurse, Tutorials, Tools und mehr auf:
    https://membership.philippelmer.com/
    Zwei Wochen kostenlos testen!
    ------------------------------



  • 6.  RE: AE REST API quirks

    Posted Nov 21, 2022 03:58 AM
    It definitely works for me. The engine is AAKE 21.0.3.


  • 7.  RE: AE REST API quirks

    Posted Nov 21, 2022 04:19 AM
    To verify, that we're talking on the same. This is with 21.0.3, but not AAKE edition. I can not imagine, that this behaviour differs. Very strange.



    ------------------------------
    ☎️ Swisscom Automation Engineer & 🧙 PE Membership Creator

    Automic Kurse, Tutorials, Tools und mehr auf:
    https://membership.philippelmer.com/
    Zwei Wochen kostenlos testen!
    ------------------------------



  • 8.  RE: AE REST API quirks

    Posted Nov 21, 2022 04:35 AM
    Edited by Michael A. Lowry Nov 21, 2022 04:36 AM
    Ah, ok. Yes, you're right; when a range is specified, the AE responds as though no status parameter were specified at all. I was assuming it was working because it was showing me the tasks I was looking for; I did not verify that it was properly excluding other tasks.

    I'd say that the behavior is still less than ideal. If an invalid parameter value is specified, the AE should return an error.



  • 9.  RE: AE REST API quirks

    Posted Nov 21, 2022 04:41 AM
    The same happened to me as well, that's why I thought I'd better send you a screenshot :-)

    ------------------------------
    ☎️ Swisscom Automation Engineer & 🧙 PE Membership Creator

    Automic Kurse, Tutorials, Tools und mehr auf:
    https://membership.philippelmer.com/
    Zwei Wochen kostenlos testen!
    ------------------------------



  • 10.  RE: AE REST API quirks

    Posted Nov 21, 2022 04:06 AM
    Here's a JOBI that will expand status ranges like the ones in ZUTYP_STATUSRANGE.

    EBM.ENUMERATE_TASK_STATUS_RANGE.JOBI

    :SET &INPUT_STRING# = &INPUT_STRING#
    ! For testing:
    !:SET &INPUT_STRING# = "1550,1541,1542,1545,1546,1551-1564,1566-1576,1578-1583,1590-1593,1682,1685,1686,1701"
    :PRINT "Input string : &INPUT_STRING#"
    :SET &OUTPUT_STRING# = ""
    :DEFINE &STRING_ARRAY#, string, 200
    :FILL &STRING_ARRAY#[] = STR_SPLIT(&INPUT_STRING#,",")
    :SET &COUNTER# = 1
    :SET &LENGTH# = LENGTH(&STRING_ARRAY#[])
    :WHILE &COUNTER# <= &LENGTH#
    : SET &ELEMENT# = &STRING_ARRAY#[&COUNTER#]
    : IF &ELEMENT# <> ""
    : SET &COUNTER# = FORMAT(&COUNTER#,"0")
    !: PRINT "Array element &COUNTER# : &ELEMENT#"
    : SET &IS_STATUS_RANGE# = STR_MATCH(&ELEMENT#,"????-????","*","?")
    : IF &IS_STATUS_RANGE# = "Y"
    !: PRINT "Element appears to be a range."
    : SET &LOWER_BOUND# = STR_CUT(&ELEMENT#,1,4)
    : SET &UPPER_BOUND# = STR_CUT(&ELEMENT#,6,4)
    !: PRINT "Lower bound : &LOWER_BOUND#"
    !: PRINT "UPPER bound : &UPPER_BOUND#"
    : SET &LOWER_BOUND_NUMERIC# = ISNUMERIC(&LOWER_BOUND#)
    : SET &UPPER_BOUND_NUMERIC# = ISNUMERIC(&UPPER_BOUND#)
    : IF &LOWER_BOUND_NUMERIC# <> "Y"
    : PRINT "WARNING: Lower bound of range &ELEMENT#, &LOWER_BOUND#, is not numeric."
    : ENDIF
    : IF &UPPER_BOUND_NUMERIC# <> "Y"
    : PRINT "WARNING: Upper bound of range &ELEMENT#, &UPPER_BOUND#, is not numeric."
    : ENDIF
    : SET &RANGE_ELEMENT# = &LOWER_BOUND#
    : WHILE &RANGE_ELEMENT# < &UPPER_BOUND#
    : SET &RANGE_ELEMENT# = FORMAT(&RANGE_ELEMENT#)
    : IF &OUTPUT_STRING# = ""
    : SET &OUTPUT_STRING# = "&RANGE_ELEMENT#"
    : ELSE
    : SET &OUTPUT_STRING# = "&OUTPUT_STRING#,&RANGE_ELEMENT#"
    : ENDIF
    : SET &RANGE_ELEMENT# = &RANGE_ELEMENT# + 1
    : ENDWHILE
    : ELSE
    : IF &OUTPUT_STRING# = ""
    : SET &OUTPUT_STRING# = "&ELEMENT#"
    : ELSE
    : SET &OUTPUT_STRING# = "&OUTPUT_STRING#,&ELEMENT#"
    : ENDIF
    : ENDIF
    : ENDIF
    : SET &COUNTER# = &COUNTER# + 1
    :ENDWHILE
    :PRINT "Output string : &OUTPUT_STRING#"
    (Higher Logic corrupts the indentation. There's not much I can do about that.)

    Enjoy!


  • 11.  RE: AE REST API quirks

    Posted Nov 21, 2022 05:33 AM

    Good morning Michael

    # has a special meaning in URLs. So you must replace #, if used as a parameter value, with %23:

    JOB.EXAMPLE#DEMO: ​​https://xxx.com/ae/api/v1/9002/executions?name=JOBP.EXAMPLE%23DEMO

    For me this works on V21.

    Regards

    Joel



    ------------------------------
    ☎️ Swisscom Automation Engineer & 🧙 PE Membership Creator

    Automic Kurse, Tutorials, Tools und mehr auf:
    https://membership.philippelmer.com/
    Zwei Wochen kostenlos testen!
    ------------------------------