<?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: Python script to DELETE objects from FMC using a CSV file in Network Security</title>
    <link>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4098942#M1070842</link>
    <description>&lt;P&gt;Here a quick and dirty python code that runs well.&lt;/P&gt;
&lt;P&gt;Sometimes objects aren't deleted because attached to a policy or whatever, so have you checked the response of your response.text?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;objectsdel = ['005056AD-AB1C-0ed3-0000-008589972365', '005056AD-AB1C-0ed3-0000-004294967567', '005056AD-AB1C-0ed3-0000-008589972347', '005056AD-AB1C-0ed3-0000-004294967636']&lt;BR /&gt;&lt;BR /&gt;url1 = "https://10.10.10.10/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/hosts/"

headers2 = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
}

headers2['X-auth-access-token'] = response.headers['X-auth-access-token']
headers2['X-auth-refresh-token'] = response.headers['X-auth-refresh-token']

for i in objectsdel:
  del_url = url1 + i
  r = requests.request("DELETE", del_url, headers=headers2, verify=False)
  status_code = r.status_code
  resp = r.text
  print(f" Status Code: {status_code}")
  print(f" text: {resp}")
  json_resp = json.loads(resp)

&lt;/PRE&gt;
&lt;P&gt;What version of FMC are you running?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 07 Jun 2020 16:19:34 GMT</pubDate>
    <dc:creator>Francesco Molino</dc:creator>
    <dc:date>2020-06-07T16:19:34Z</dc:date>
    <item>
      <title>Python script to DELETE objects from FMC using a CSV file</title>
      <link>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4097472#M1070737</link>
      <description>&lt;P&gt;&lt;FONT color="#000000"&gt;I have a fully working python script that can POST objects to the FMC API using a .csv file for the data.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;FMC is 6.5.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I want to use this same approach/method to DELETE objects, but after many hours I have been unable to get the script to work.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Due to the errors I receive, I have to assume that there is something wrong in how my python script builds the URL, as the URL I intend to use, works when tested from POSTMAN.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I have looked extensively for sample deletion scripts, but the ones I can find all approach the deletion by deleting "all unused". As I am building a 10K object environment and I do not yet have any ACP, all my objects are currently unused.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Can anyone point out what the issue is please?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Error Messages&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;I get:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;&lt;EM&gt;Status code: 400&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt;&lt;EM&gt;Message: {"error":{"category":"FRAMEWORK","messages":[{"description":"Wrong URL for delete request."}],"severity":"ERROR"}}&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;This is why I believe the issue is an incorrect URL.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The object ID can be seen in my log entry as correct and picked up from the csv file:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;&lt;EM&gt;Deleting object: 005056A6-6972-0ed3-0000-090194314100&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The&lt;EM&gt; "Deleting object:" words come from my script&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The object ID has been taken from the .csv file&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;(The objects in the .csv are compiled from a separate script operation and the .csv file is confirmed as correct (it has exactly the same format as the script used to POST objects and has been checked for erroneous spaces etc)).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;This is the URL I am trying to form:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;https://&lt;STRIKE&gt;&amp;lt;FMCNAME&amp;gt;&lt;/STRIKE&gt;/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f&lt;FONT color="#FF0000"&gt;/object/hosts/&lt;/FONT&gt;005056A6-6972-0ed3-0000-090194314010&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;This URL works perfectly from POSTMAN and the host get deleted.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;U&gt;&lt;STRONG&gt;Working Script&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;This is how the &lt;STRONG&gt;working&lt;/STRONG&gt; POST objects from csv script builds the URL:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;api_path = "/api/fmc_config/v1/domain/" + auth_domain + &lt;FONT color="#FF0000"&gt;"/object/hosts"&lt;/FONT&gt;&lt;BR /&gt;url = server + api_path&lt;BR /&gt;if (url[-1] == '/'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; url = url[:-1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for object in objects:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; post_data = {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "name": object["name"],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "type": object["type"],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "value": object["value"],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "description": object["description"],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;print('\n*********************************')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print('Creating object: ' + object["name"])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; try:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; r = requests.&lt;FONT color="#FF0000"&gt;post&lt;/FONT&gt;(url, data=json.dumps(post_data), headers=headers, verify=False)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; status_code = r.status_code&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; resp = r.text&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; log = open('post_objects.log', 'a')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(" Status code: "+str(status_code))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; json_resp = json.loads(resp)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; log.write('\n----------------------------------------------------\n')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; log.write(json.dumps(json_resp,sort_keys=True,indent=4, separators=(',', ': ')))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The csv is formatted as:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;name,value,type,description&lt;BR /&gt;test-name1,10.1.1.1,host,host1&lt;BR /&gt;test-name2,10.1.1.2,host,host2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The only difference I can see in the URL between the POST and DELETE operations is a single "/" at the end of the path.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;API explorer paths:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Object POST path&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="opblock-summary-method"&gt;POST&lt;/SPAN&gt;&lt;SPAN class="opblock-summary-path"&gt;&lt;A target="_blank"&gt;/api/fmc_config/v1/domain/{domainUUID}/object/hosts&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;Object DELETE path&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;&lt;SPAN&gt;&lt;SPAN class="opblock-summary-method"&gt;DELETE&lt;/SPAN&gt;&lt;SPAN class="opblock-summary-path"&gt;&lt;A target="_blank"&gt;/api/fmc_config/v1/domain/{domainUUID}/object/hosts/{objectId}&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;U&gt;&lt;STRONG&gt;Failing Script&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;This is how the DELETE&amp;nbsp;objects from csv script builds the URL:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;api_path = "/api/fmc_config/v1/domain/" + auth_domain + &lt;FONT color="#FF0000"&gt;"/object/hosts/"&lt;/FONT&gt;&lt;BR /&gt;url = server + api_path&lt;BR /&gt;if (url[-1] == '/'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; url = url[:-1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for object in objects:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; del_data = {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "objectid": object["objectid"]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;print('\n***********************************')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print('Deleting object: ' + object["objectid"])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; try:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; r = requests.&lt;FONT color="#FF0000"&gt;delete&lt;/FONT&gt;(url, data=json.dumps(del_data), headers=headers, verify=False)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; status_code = r.status_code&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; resp = r.text&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; log = open('delete_objects.log', 'a')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(" Status code: "+str(status_code))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; json_resp = json.loads(resp)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; log.write('\n----------------------------------------------------\n')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; log.write(json.dumps(json_resp,sort_keys=True,indent=4, separators=(',', ': ')))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The csv is formatted as:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;name,value,objectid&lt;BR /&gt;test-name1,10.1.1.1,&lt;EM&gt;005056A6-6972-0ed3-0000-090194314010&lt;/EM&gt;&lt;BR /&gt;test-name2,10.1.1.2,005056A6-6972-0ed3-0000-090194313992&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The failing script collects the name, user id and password and then runs through the entire csv file. Each deletion attempt collects the correct item from the csv and then fails with the same URL error message. The script then completes as expected.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Thanks in advance for your assistance.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 10:06:29 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4097472#M1070737</guid>
      <dc:creator>Maneck_UK</dc:creator>
      <dc:date>2020-06-04T10:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to DELETE objects from FMC using a CSV file</title>
      <link>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4098035#M1070786</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;You’re putting the objectid in the body but it should normally be in the url itself:&lt;BR /&gt;&lt;BR /&gt;curl -X DELETE "https://fmc-fqdn/api/fmc_config/v1/domain/11111-1111-1111-1111-abcdef/object/hosts/005056A6-6972-0ed3-0000-090194314010" -H "accept: application/json" -H "X-auth-access-token: aaaaaa-aaaaaaa-aaaaa"</description>
      <pubDate>Fri, 05 Jun 2020 04:19:24 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4098035#M1070786</guid>
      <dc:creator>Francesco Molino</dc:creator>
      <dc:date>2020-06-05T04:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to DELETE objects from FMC using a CSV file</title>
      <link>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4098094#M1070788</link>
      <description>&lt;P&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/321306"&gt;@Francesco Molino&lt;/a&gt;&amp;nbsp;Thank you!&lt;/P&gt;&lt;P&gt;That makes sense.&lt;/P&gt;&lt;P&gt;I will look to see how to add the csv object routine to the url component of the script.&lt;/P&gt;&lt;P&gt;If anyone has any pointers they would be very much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 08:25:38 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4098094#M1070788</guid>
      <dc:creator>Maneck_UK</dc:creator>
      <dc:date>2020-06-05T08:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to DELETE objects from FMC using a CSV file</title>
      <link>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4098836#M1070830</link>
      <description>&lt;P&gt;&lt;FONT color="#000000"&gt;I've spent a lot more time trying to get this to work and continue to fail.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I can get a single object to delete if I add the url object ID data to the script for a single object.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;like this: del_data = ['005056A6-6972-0ed3-0000-090194313992']&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;But this defeats the purpose of the script.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I believe I now have a correct url built from the csv file but I continue to get 404 incorrect url errors:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I'd very much appreciate any pointers as to where I'm going wrong with my python script, as you may be able to tell I'm new to this python scripting business.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Error message when using new CSV script&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Error in connection --&amp;gt; 404 Client Error: Not Found for url: https://&lt;STRIKE&gt;&amp;lt;FMC-NAME&amp;gt;&lt;/STRIKE&gt;/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/hosts/005056A6-6972-0ed3-0000-090194314504&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;URL build script component&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;f = open("delid.csv")&lt;BR /&gt;objectsfile = csv.DictReader(f)&lt;/P&gt;&lt;P&gt;for object in objectsfile:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; del_data = {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; object["objectid"]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;for object in del_data:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; del_url = server + api_path + object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; r = requests.delete(del_url, headers=headers, verify=False)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; status_code = r.status_code&lt;BR /&gt;&amp;nbsp; &amp;nbsp; resp = r.text&lt;BR /&gt;&amp;nbsp; &amp;nbsp; log = open('delete_objects.log', 'a')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print(" Status Code: "+str(status_code))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; json_resp = json.loads(resp)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;log.write(json.dumps(json_resp,sort_keys=True,indent=4, separators=(',', ': ')))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if status_code == 201 or status_code == 202:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(" SUCCESS ")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif status_code == 400:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print((" Message: ")+ resp + ('\n'))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; else:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; r.raise_for_status()&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print((" Message: ")+ resp + ('\n'))&lt;/P&gt;&lt;P&gt;except requests.exceptions.HTTPError as err:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print("Connection Error --&amp;gt; "+str(err))&lt;BR /&gt;finally:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if r: r.close()&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jun 2020 10:41:42 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4098836#M1070830</guid>
      <dc:creator>Maneck_UK</dc:creator>
      <dc:date>2020-06-07T10:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to DELETE objects from FMC using a CSV file</title>
      <link>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4098942#M1070842</link>
      <description>&lt;P&gt;Here a quick and dirty python code that runs well.&lt;/P&gt;
&lt;P&gt;Sometimes objects aren't deleted because attached to a policy or whatever, so have you checked the response of your response.text?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;objectsdel = ['005056AD-AB1C-0ed3-0000-008589972365', '005056AD-AB1C-0ed3-0000-004294967567', '005056AD-AB1C-0ed3-0000-008589972347', '005056AD-AB1C-0ed3-0000-004294967636']&lt;BR /&gt;&lt;BR /&gt;url1 = "https://10.10.10.10/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/hosts/"

headers2 = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
}

headers2['X-auth-access-token'] = response.headers['X-auth-access-token']
headers2['X-auth-refresh-token'] = response.headers['X-auth-refresh-token']

for i in objectsdel:
  del_url = url1 + i
  r = requests.request("DELETE", del_url, headers=headers2, verify=False)
  status_code = r.status_code
  resp = r.text
  print(f" Status Code: {status_code}")
  print(f" text: {resp}")
  json_resp = json.loads(resp)

&lt;/PRE&gt;
&lt;P&gt;What version of FMC are you running?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jun 2020 16:19:34 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4098942#M1070842</guid>
      <dc:creator>Francesco Molino</dc:creator>
      <dc:date>2020-06-07T16:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to DELETE objects from FMC using a CSV file</title>
      <link>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4099008#M1070846</link>
      <description>&lt;P&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/923049"&gt;@JonasKs&lt;/a&gt;&amp;nbsp;Many thanks for helping me with the solution. I doubt I would have finished with your help.&lt;/P&gt;&lt;P&gt;Hotfix from Cisco Devnet provided the how to for my script.&lt;/P&gt;&lt;P&gt;I got it working with his helpers which disappointingly vanished as they provided excellent scripting info.&lt;/P&gt;&lt;P&gt;Hotfix then added additional polish to my script which actually worked without the suggested changes.&lt;/P&gt;&lt;P&gt;Please find the both my final script and the polished one from hotfix.&lt;/P&gt;&lt;P&gt;&lt;LI-MESSAGE title="404 error in Python script to DELETE objects from FMC using a CSV file" uid="4098838" url="https://community.cisco.com/t5/security-discussions/404-error-in-python-script-to-delete-objects-from-fmc-using-a/m-p/4098838#U4098838"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jun 2020 19:09:50 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/python-script-to-delete-objects-from-fmc-using-a-csv-file/m-p/4099008#M1070846</guid>
      <dc:creator>Maneck_UK</dc:creator>
      <dc:date>2020-06-07T19:09:50Z</dc:date>
    </item>
  </channel>
</rss>

