<?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: XSOAR 8 API - Attachment upload with entryID in Cortex XSOAR Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/xsoar-8-api-attachment-upload-with-entryid/m-p/565844#M2831</link>
    <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/287891"&gt;@gyldz&lt;/a&gt;&amp;nbsp; Thanks for the reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It gives the below as response. I gave in the incident ID not sure why we are getting this.&lt;/P&gt;
&lt;P&gt;{'id': 'noInv', 'status': 400, 'title': 'Could not find investigations', 'detail': 'Could not find investigation', 'error': 'Could not find investigations:Could not find investigation', 'encrypted': False, 'multires': None}&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Nov 2023 15:29:43 GMT</pubDate>
    <dc:creator>Moh.Yasser</dc:creator>
    <dc:date>2023-11-15T15:29:43Z</dc:date>
    <item>
      <title>XSOAR 8 API - Attachment upload with entryID</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/xsoar-8-api-attachment-upload-with-entryid/m-p/563462#M2780</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The code below, creates an incident with attachment uploaded but in the incident itself, when I see the context, I dont see any file.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Since there is no entryID for the file, I cannot read the attachment and also cannot run the playbooks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any change I need to make to make the attachment appear as File with entryID?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR-8-API/Incidents" target="_blank"&gt;https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR-8-API/Incidents&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;---------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;&lt;SPAN&gt;from datetime import datetime, timezone&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import secrets&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import string&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import hashlib&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import requests&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def test_advanced_authentication(api_key_id, api_key, attachments, file):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Generate a 64 bytes random string&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;nonce = "".join([secrets.choice(string.ascii_letters + string.digits) for _ in range(64)])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Get the current timestamp as milliseconds.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;timestamp = int(datetime.now(timezone.utc).timestamp()) * 1000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Generate the auth key:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;auth_key = "%s%s%s" % (api_key, nonce, timestamp)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Convert to bytes object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;auth_key = auth_key.encode("utf-8")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Calculate sha256:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;api_key_hash = hashlib.sha256(auth_key).hexdigest()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Generate HTTP call headers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;headers = {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"x-xdr-timestamp": str(timestamp),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"x-xdr-nonce": nonce,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"x-xdr-auth-id": str(api_key_id),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"Authorization": api_key_hash&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;parameters = {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"name": " Incident - " + file,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"severity": 3,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"type": "Spam Emails",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"attachment": attachments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;res = requests.post(url="&lt;/SPAN&gt;&lt;A href="https://api-url/xsoar/public/v1/incident" target="_blank" rel="noopener"&gt;https://api-URL/xsoar/public/v1/incident&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;headers=headers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;json=parameters, verify=False)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print(res.json())&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;return res&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Specify the folder path&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;folder_path = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# List all files in the folder&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;files = os.listdir(folder_path)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;first_5_files = files[:5]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Loop through the list of files&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;api_key = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;apiid =&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for file in first_5_files:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Print the file name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print(file)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;path = folder_path + "\\" + file&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;attachments = [{"name": file, "path": str(path)}]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print(test_advanced_authentication(apiid, api_key, attachments, file))&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2023 05:33:56 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/xsoar-8-api-attachment-upload-with-entryid/m-p/563462#M2780</guid>
      <dc:creator>Moh.Yasser</dc:creator>
      <dc:date>2023-10-29T05:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: XSOAR 8 API - Attachment upload with entryID</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/xsoar-8-api-attachment-upload-with-entryid/m-p/565791#M2830</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/290616"&gt;@Moh.Yasser&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After the creating the incident, you can get the incident id. (res.json().get(id)) and run the below something like below.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;file&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;"/abc/xyz/test.txt"&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;files&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;'file'&lt;/SPAN&gt;&lt;SPAN&gt; : (&lt;/SPAN&gt;&lt;SPAN&gt;'test.txt'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;open&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;file&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'rb'&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;'text/plain'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;data&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;'fileName'&lt;/SPAN&gt;&lt;SPAN&gt; : &lt;/SPAN&gt;&lt;SPAN&gt;'test.txt'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;'fileComment'&lt;/SPAN&gt;&lt;SPAN&gt; : &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;'showMediaFile'&lt;/SPAN&gt;&lt;SPAN&gt; : &lt;/SPAN&gt;&lt;SPAN&gt;"false"&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;url&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;f&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;A href="https://xsoarurl/xsoar/entry/upload/incident_id" target="_blank"&gt;https://xsoarurl/xsoar/entry/upload/incident_id&lt;/A&gt;"&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;r&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;requests&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;post&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;url&lt;/SPAN&gt;&lt;SPAN&gt;, data&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;data&lt;/SPAN&gt;&lt;SPAN&gt;, files&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;files&lt;/SPAN&gt;&lt;SPAN&gt;, headers&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;headers&lt;/SPAN&gt;&lt;SPAN&gt;, verify&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;False&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 Nov 2023 10:02:07 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/xsoar-8-api-attachment-upload-with-entryid/m-p/565791#M2830</guid>
      <dc:creator>gyldz</dc:creator>
      <dc:date>2023-11-15T10:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: XSOAR 8 API - Attachment upload with entryID</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/xsoar-8-api-attachment-upload-with-entryid/m-p/565844#M2831</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/287891"&gt;@gyldz&lt;/a&gt;&amp;nbsp; Thanks for the reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It gives the below as response. I gave in the incident ID not sure why we are getting this.&lt;/P&gt;
&lt;P&gt;{'id': 'noInv', 'status': 400, 'title': 'Could not find investigations', 'detail': 'Could not find investigation', 'error': 'Could not find investigations:Could not find investigation', 'encrypted': False, 'multires': None}&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 15:29:43 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/xsoar-8-api-attachment-upload-with-entryid/m-p/565844#M2831</guid>
      <dc:creator>Moh.Yasser</dc:creator>
      <dc:date>2023-11-15T15:29:43Z</dc:date>
    </item>
  </channel>
</rss>

