Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Trigger UI action through rest api call

scocuzza
Kilo Contributor

Hello,

I want to be able to trigger a UI action that is located on a record on a specific table

I tried using this method found in this link: https://servicenowthink.wordpress.com/2019/10/15/call-any-ui-action-with-rest-api-or-ajax-ootb-updat...

 

This is in python:

url = 'https://URLHERE/api/now/ui/ui_action/sys_id_of_ui_action?' \
'sysparm_table=table_of_target_record&' \
'sysparm_sys_id=' sys_id_of_target_record& '\

'api=api'


headers = {"Content-Type":"application/json","Accept":"application/json"}
response = requests.post(url, auth=(user, pwd), headers=headers, verify = False )

if response.status_code != 200 and response.status_code != 201:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
exit()

data = response.json()

 

and i am receiving 

{
    "error": {
        "message": "A JSONObject text must begin with '{' at character 0 of ",
        "detail": "A JSONObject text must begin with '{' at character 0 of "
    },
    "status": "failure"
}
 
is this even possible to perform?
7 REPLIES 7

Aleksas Kucins1
Giga Expert
Try adding this to your body: { "fields": [ { "name": "" } ] }

I received 201 created through postman but it actually didnt do anything when i checked the record.

 

I manually pushed the ui action to check it there was anything stopping the ui action from going through but there was nothing

 

find_real_file.pngfind_real_file.png

Can you show the contents of UI action?

This is the XML of the UI action
find_real_file.png