<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to use Python Query arguments in workflow script in Cisco XDR</title>
    <link>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253308#M11</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-01-27 at 16.30.56.png" style="width: 451px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/238605i4B0CC2CB0FD82CA5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-01-27 at 16.30.56.png" alt="Screenshot 2025-01-27 at 16.30.56.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Not that this is documented anywhere, but you hit the (X) and click on the variable that you wish to use.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jan 2025 16:31:50 GMT</pubDate>
    <dc:creator>Arthur Dent</dc:creator>
    <dc:date>2025-01-27T16:31:50Z</dc:date>
    <item>
      <title>How to use Python Query arguments in workflow script</title>
      <link>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253273#M7</link>
      <description>&lt;P&gt;Hi all.&lt;/P&gt;
&lt;P&gt;Quite simply: I'm receiving a webhook from Meraki, extracting the relevent information using JSONPath Query, and can see them when viewing the run of the workflow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I've yet to work out how to actually use these within the python script that follows the JSONPath Query.&lt;/P&gt;
&lt;P&gt;os.environ doesn't work, nor does&amp;nbsp;&lt;/P&gt;
&lt;PRE class="lang-py s-code-block"&gt;&lt;CODE class="hljs language-python" data-highlighted="yes"&gt;&lt;SPAN class="hljs-built_in"&gt;print&lt;/SPAN&gt;(sys.argv) &lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE class="lang-py s-code-block"&gt;&lt;CODE class="hljs language-python" data-highlighted="yes"&gt;args = parser.parse_args())&lt;/CODE&gt;&lt;CODE class="hljs language-python" data-highlighted="yes"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Quite simply, how do I see the script arguments from within the Python?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 15:46:27 GMT</pubDate>
      <guid>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253273#M7</guid>
      <dc:creator>Arthur Dent</dc:creator>
      <dc:date>2025-01-27T15:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Python Query arguments in workflow script</title>
      <link>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253288#M8</link>
      <description>&lt;P&gt;By no means an expert on this, but to&amp;nbsp;&lt;SPAN&gt;use query arguments or extracted data from a webhook in a Python script within your workflow, you would needs to pass the data from the previous step ( this is your JSONPath Query) to the Python script. But... the exact method depends which workflow automation tool you're using (this might change if you are using Zapier, Make, n8n, or your own custom build etc.. ) So for example i&lt;/SPAN&gt;f say you are using a tool like Zapier or Make, the output of the JSONPath Query step is typically available as input to the next step which is your Python script.&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 16:08:08 GMT</pubDate>
      <guid>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253288#M8</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2025-01-27T16:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Python Query arguments in workflow script</title>
      <link>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253295#M9</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-01-27 at 16.12.03.png" style="width: 924px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/238604i957D6EB96A608CAC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-01-27 at 16.12.03.png" alt="Screenshot 2025-01-27 at 16.12.03.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;This is just a simple webhook, and as you can see, I can see the script arguments that I've created using variables. All good so far, but nothing I try allows me to see these variables within Python script&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 16:15:10 GMT</pubDate>
      <guid>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253295#M9</guid>
      <dc:creator>Arthur Dent</dc:creator>
      <dc:date>2025-01-27T16:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Python Query arguments in workflow script</title>
      <link>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253303#M10</link>
      <description>&lt;P&gt;Arh ok.. try and add print statement at the beginning of your script to inspect what is being passed in (you could also use&amp;nbsp;&lt;SPAN&gt;sys.argv if this is supported).&amp;nbsp;This should tell you what variables are available to your script, you can look for a variable that contains your arguments, i would guess it might be something like &lt;CODE&gt;args&lt;/CODE&gt;, &lt;CODE&gt;arguments&lt;/CODE&gt;, &lt;CODE&gt;input_data&lt;/CODE&gt;, or similar.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;print(dir()) 
print(globals())
print(locals()) &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Saw you used sys.argv above. Maybe&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import sys

# Print all arguments for debugging
print("Script arguments:", sys.argv)

# Access specific arguments
if len(sys.argv) &amp;gt; 1:
    arg1 = sys.argv[1]  # First argument
    arg2 = sys.argv[2]  # Second argument
    arg3 = sys.argv[3]  # Third argument
    print(f"Argument 1: {arg1}")
    print(f"Argument 2: {arg2}")
    print(f"Argument 3: {arg3}")
else:
    print("No arguments provided.")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 16:27:04 GMT</pubDate>
      <guid>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253303#M10</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2025-01-27T16:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Python Query arguments in workflow script</title>
      <link>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253308#M11</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-01-27 at 16.30.56.png" style="width: 451px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/238605i4B0CC2CB0FD82CA5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-01-27 at 16.30.56.png" alt="Screenshot 2025-01-27 at 16.30.56.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Not that this is documented anywhere, but you hit the (X) and click on the variable that you wish to use.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 16:31:50 GMT</pubDate>
      <guid>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253308#M11</guid>
      <dc:creator>Arthur Dent</dc:creator>
      <dc:date>2025-01-27T16:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Python Query arguments in workflow script</title>
      <link>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253314#M12</link>
      <description>&lt;P&gt;Interesting this might explain why your standard Python argument passing mechanisms were not working as the meraki platform is handling the data transfer behind the scenes. Hmm so say for example&lt;SPAN&gt;&amp;nbsp;you might have a JSONPath Query that extracts&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;organizationId&lt;/CODE&gt;&lt;SPAN&gt;, you can insert it into your script as shown in your screenshot, then you can insert this&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;print("Start")
someVar = JSONPath Query...organizationId  # Inserted variable
print("Organization ID:", someVar)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;This should print the value of&amp;nbsp;&lt;CODE&gt;organizationId&lt;/CODE&gt;&amp;nbsp;extracted by the JSONPath Query. But guessing here.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 16:48:39 GMT</pubDate>
      <guid>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5253314#M12</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2025-01-27T16:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Python Query arguments in workflow script</title>
      <link>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5254086#M13</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/559516"&gt;@Arthur Dent&lt;/a&gt;&amp;nbsp;, you can do 2 things to use script variables, and I agree that we can better document that here: &lt;A href="https://docs.xdr.security.cisco.com/Content/Automate/activities-python-execute-python-script.html" target="_blank"&gt;https://docs.xdr.security.cisco.com/Content/Automate/activities-python-execute-python-script.html&lt;/A&gt;. I will make sure we update that section.&lt;BR /&gt;&lt;BR /&gt;What you need to do is add the variables as script argument (like you did), and then you can reference it like&amp;nbsp;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/352839"&gt;@bigevilbeard&lt;/a&gt;&amp;nbsp;recommended:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import sys

my_first_script_argument = sys.argv[1]&lt;/LI-CODE&gt;
&lt;P&gt;Another option is to reference the variable directly in the script, as you did in your second screenshot. Both work, and some prefer one over the other. As I mentioned, I will make sure we better document this.&lt;BR /&gt;&lt;BR /&gt;Just so you know, we have a lot of labs on DevNet that teach you these kind of things:&amp;nbsp;&lt;A href="https://developer.cisco.com/learning/tracks/cisco-xdr/cisco-xdr-automation/" target="_blank"&gt;https://developer.cisco.com/learning/tracks/cisco-xdr/cisco-xdr-automation/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 08:16:46 GMT</pubDate>
      <guid>https://community.cisco.com/t5/cisco-xdr/how-to-use-python-query-arguments-in-workflow-script/m-p/5254086#M13</guid>
      <dc:creator>chrivand</dc:creator>
      <dc:date>2025-01-29T08:16:46Z</dc:date>
    </item>
  </channel>
</rss>

