API Syntax Issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API Syntax Issue

L1 Bithead

Hi everyone,

 

I'm trying to use the 'run_script' API to start the built-in 'Execute_Commands' script on a target machine. I've worked through a few error messages already regarding the command string having black slashes, timeout not being set as integer etc. Now Cortex is telling me I'm missing some parameters from the API call. I have no idea what to change at this point. Any documentation I've found online lists the general parts needed for the API call, without a specific worked example for syntax etc. Below I've posted the JSON and cUrl commands I'm using. Has anyone successfully executed an API call for 'run_script' ? What am I missing?

 

Thanks,

 

 

My CUrl command (supplying JSON for parameters in separate file): 

curl -o c:\temp\run_script_results.txt -X POST -H "x-xdr-auth-id:99" -H "Authorization:GsdfdfDFSsdgfs45354dfsfSDFDSfdfsdsfsdfsdfsfssdfsdfsdfdsf" -H "Content-Type:application/json" "https://<fqdn>.xdr.us.paloaltonetworks.com/public_api/v1/scripts/run_script" -d @"c:\temp\json5.txt"

 

 

Body JSON for run_script per Cortex API Docs
{
   "request_data":{
   "filters":[
      {
         "field":"endpoint_id_list",
         "operator":"in",
         "value":[
            "<endpoint ID>"
         ]
      }
   ],
   "script_uid":"<unique ID>",
   "parameters_values":{
      "x":"param input as returned in Get Script Metadata",
      "y":4
   }
}
}
 
My JSON file (got script UID from get_metadata script):
 

{
"request_data":{
"filters":[
{
"field":"endpoint_id_list",
"operator":"in",
"value":[
"0c14fh74hjhfejwleur3sfj43c2e"
]
}
],
"script_uid":"a0c14fh74hjhfejwleur3sfsdf3333sfgdfw6bf",
"parameters_values":{
"commands_list":"cmd /c type c:\\temp\\WTInv.txt",
"type": "list",
"list_type": "string"},
"script_output_type": "dictionary",
"script_output_dictionary_definitions": ["action_id","status","endpoints_count"],    <<< Left this definitions part empty, got same error.
"timeout":600

}
}

 

 

Error Message Seen when running cUrl above:

 

{"reply": {"err_code": 500, "err_msg": "An error occurred while processing XDR public API", "err_extra": "parameters_values contain invalid/missing parameters"}}

 

1 REPLY 1

L5 Sessionator

Hello  @cnogawaterfront ,

 

Are you trying to run the specific command ("commands_list":"cmd /c type c:\\temp\\WTInv.txt")

 

If yes, then why not you create just one script to run the above command and use it. 

Ashutosh Patil
  • 231 Views
  • 1 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!