When using curl command to make API calls, the process fails with no errors!
search cancel

When using curl command to make API calls, the process fails with no errors!

book

Article ID: 384058

calendar_today

Updated On:

Products

Autosys Workload Automation

Issue/Introduction

When using curl on the command line on Linux some Autosys API calls work as expected and others do not.
A working curl call:
# autorep -g MyGlobalVariable
Global Name              Value                Last Changed
________________________________________________________________________________
MyGlobalVariable     GrandCentral     02/11/2021 15:43:14

# curl -k -X GET --user ${user} https:/<PrimaryScheduler>:<AppPort>/AEWS/gvar/MyGlobalVariable -H "Content-Type: application/json" | json_pp

% Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 182 0 182 0 0 71 0 --:--:-- 0:00:02 --:--:-- 71
{
 "value" : "GrandCentral",
 "updateTime" : "2021-02-11T20:43:14+0000",
 "self" : {
 "@href" : "https://<PrimaryScheduler>:<AppPort>/AEWS/gvar/MyGlobalVariable",
 "@rel" : "self"
 },
 "name" : "MyGlobalVariable"
}

Not working CURL call:
# curl -k -X POST --user ${user} https://<PrimaryScheduler>:<AppPort>/AEWS/event/set-gvar/MyGlobalVariable --data {"gvarValue":"Wednesday"} -H "Content-Type: application/json"

# autorep -g MyGlobalVariable
Global Name Value Last Changed
___________________________________________________________________________
MyGlobalVariable GrandCentral 02/11/2021 15:43:14



Environment

Autosys 12.x
Linux

Cause

The problem is how Linux deals with double quotes on the command line interface

Resolution

Double quotes must be escaped.
Example:
Testing for value:
# autorep -g MyTESTVariable
CAUAJM_E_50182 Invalid Global Variable Name: MyTESTVariable

Rest API call using CURL:
# curl -k -X POST --user ${user} https://<PrimaryScheduler>:<AppPort>/AEWS/event/set-gvar/MyTESTVariable  -d {\"gvarValue\":\"NewVariable\"} -H "Content-Type: application/json"

Validating new value:
# autorep -g MyTESTVariable
Global Name                                   Value                                    Last Changed
_______________________________________________________________
MyTESTVariable                        NewVariable                    12/11/2024 15:49:27