Automic Workload Automation

 View Only

  • 1.  Job execution via REST API using curl

    Posted Aug 20, 2024 06:03 AM

    Hi Team

    The customer has a requirement to execute a workflow via the REST API using curl but it's not working.

    The user do exist and listening on port 8088

    Currently the password is not encoded - next step

    Below is the code and output

    curl -D- --basic -u RESTAPI/JDE:'password' -X POST -H "Content-Type: application/json" http://serverxyz:8088/ae/api/v1/20/executions -d "{\"object_name\":\"DH.MAIN_WF\"}"

    OUTPUT:

    HTTP/1.1 401 Unauthorized
    Date: Tue, 20 Aug 2024 08:47:59 GMT
    Content-Type: application/json
    WWW-Authenticate: Basic realm="AUTOMIC"
    Content-Length: 116

    {
      "code" : 45254,
      "error" : "The credentials are not valid.",
      "details" : "No detail information available."

    Any help with be appreciated

    Klaus



  • 2.  RE: Job execution via REST API using curl

    Posted Aug 20, 2024 12:34 PM
    Hi Klaus,
     
    The command you shared is working perfectly. However, please ensure that the password is not enclosed in quotes. The single quotes in the command might be considered as part of the password during authentication. The password should be entered as plain text, like this:
     
    curl -D- --basic -u RESTAPI/JDE:password -X POST -H "Content-Type: application/json" http://serverxyz:8088/ae/api/v1/20/executions -d "{\"object_name\":\"DH.MAIN_WF\"}"
     
    Regards, 
    Danish



  • 3.  RE: Job execution via REST API using curl

    Posted Aug 29, 2024 03:04 AM

    waht about password encrypten using api?




  • 4.  RE: Job execution via REST API using curl

    Posted Aug 29, 2024 03:22 AM

    Hi Bastian

    I converted the username and password into a bearer token.

    A bearer token is nothing else than a base64 encoded representation of the username and password.

    For example you can go to https://www.debugbear.com/basic-auth-header-generator enter your username and pass and use the generated token instead:

    Username format:USERNAME/DEPT:password

    curl -L -X POST 'http://server:8088/ae/api/v1/0100/executions' -H 'Content-Type: application/json' -H 'Authorization: Basic TYRERFSS9SRVNUOjEyMw==' -d '{"object_name":"XYZ_WF"}'

    Regards

    Klaus




  • 5.  RE: Job execution via REST API using curl

    Posted Aug 30, 2024 12:25 PM

    For password encryption, I use Automic built in objects. I modified UC_LOGIN_TYPES in client 0 to have Internal type. (only custom login types can be for the below)

    I created a new login object using Internal with a username password, named "LOGIN.CUSTOM". In this case the user is "RESTAPI/JDE" and password is password

    :SET &USER# = GET_LOGIN(LOGIN.CUSTOM,serverxyz,INTERNAL,LOGIN_INFO)
    :SET &PASS# = GET_LOGIN(LOGIN.CUSTOM,serverxyz,INTERNAL,PASSWORD)

    &UC_JOBMD CMD="curl -D- --basic -u &USER#:&PASS# -X POST -H "Content-Type: application/json" http://serverxyz:8088/ae/api/v1/20/executions -d '{\"object_name\":\"DH.MAIN_WF\"}'"

    You might need to do some work with the quotes due to the entire command being inside them.