Automic Workload Automation

 View Only
  • 1.  Problem with AE REST API call (POST call)

    Posted Oct 22, 2019 11:06 AM
    Hello,

    I am new in using AE REST API, I am just doing my first attempts with AE 12.2.

    My attempts to fetch data via GET were successful.
    But now with using POST to add comment to an existing runid I run in trouble.
    The UC4 user has full rights.

    I do all my tests in Powershell. Here I am using Invoke-WebRequest.

    The only header I send is authentication header.

    Invoke-WebRequest : {
    "code" : 45110,
    "error" : "An Automation Engine internal error occured.",
    "details" : "RESTEASY003200: Could not find message body reader for type: class com.automic.rest.api.request.InAddCommentBody of content type: application/x-www-form-urlencoded"
    }

    This is my Powershell code that I use.

    $base_url_direct = "https://uc4-server:8088/

    $client
     = "9000"

    $user = "user"
    $pass = "password"
    $basicauth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($user+":"+$pass))

    $headers = @{}
    $headers.add("Authorization", "Basic $basicauth")

    $runid = "2988412"

    $url = $base_url_direct+"/ae/api/v1/$client/executions/$runid/comments"
    $body = convertto-json @{comment="comment by rest"}

    $result = ""
    $result = Invoke-WebRequest -Method POST -Headers $headers -Uri $url -Body $body -DisableKeepAlive

    Any help would be appreciated.


    Regards
    Joachim



    ------------------------------
    Service Manager JobManagement
    Daimler
    ------------------------------


  • 2.  RE: Problem with AE REST API call (POST call)
    Best Answer

    Posted Oct 22, 2019 06:54 PM
    Hey Joachim,

    I was able to get this working in my environment. I believe the missing link for you here is : -ContentType 'application/json' in your Invoke-Webrequest command.

    From the Invoke-Webrequest docu: If this parameter is omitted and the request method is POST, Invoke-WebRequest sets the content type to application/x-www-form-urlencoded

    Based on that error you got I would start with that.