Trouble deleting custom url category using API

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

Trouble deleting custom url category using API

L0 Member

I am trying to delete a specific custom-url-category list member using the XML API.  The system either responds with an object not found error or it deletes all members in the list.

This is what I get when i show lists:

<response status="success" code="19"><result total-count="1" count="1"><list admin="admin" time="2012/05/25 21:59:11"><member admin="admin" time="2012/05/25 21:59:04">www.somesite.com</member><member admin="admin" time="2012/05/25 21:59:11">chris.com</member></list></result></response>

Here is the command that I am using that deletes all records:

wget "https://x.x.x.x/api/?type=config&action=delete&key=key&xpath=/config/devices/entry/vsys/entry[@name='vsys1']/profiles/custom-url-category/entry[@name='CIRT_Blocks']/list&element=<member>chris.com</member>" --no-check-certificate -O response.txt

This command returns not found:

wget "https://x.x.x.x/api/?type=config&action=delete&key=key&xpath=/config/devices/entry/vsys/entry[@name='vsys1']/profiles/custom-url-category/entry[@name='CIRT_Blocks']/list/member['chris.com']" --no-check-certificate -O response.txt

or

wget "https://x.x.x.x/api/?type=config&action=delete&key=key&xpath=/config/devices/entry/vsys/entry[@name='vsys1']/profiles/custom-url-category/entry[@name='CIRT_Blocks']/list[@member='chris.com']" --no-check-certificate -O response.txt

How do I delete a single member from the list?

Thanks,

Matt

1 accepted solution

Accepted Solutions

L3 Networker

[didn't like my reply with mutt; try again, this time with webui]

you want to use the XPath text() function, for example:

$ panxapi -t pa-200 -d "/config/devices/entry/vsys/entry/profiles/custom-url-category/entry[@name='t1']/list/member[text()='chris.com']"
delete: success: command succeeded

Message was edited by: ksteves

View solution in original post

3 REPLIES 3

L3 Networker

[didn't like my reply with mutt; try again, this time with webui]

you want to use the XPath text() function, for example:

$ panxapi -t pa-200 -d "/config/devices/entry/vsys/entry/profiles/custom-url-category/entry[@name='t1']/list/member[text()='chris.com']"
delete: success: command succeeded

Message was edited by: ksteves

how about deleting multiple URL's at the same time? 

I'd like to do something where I dynamically update a custom url category.  I'm currently thinking on 2 calls to the API - one to add URL's that need to be added, the other to delete the ones that need to be deleted.  I can currently populate a list with the following options:

{'action': 'set',

'xpath': "/config/shared/profiles/custom-url-category/entry[@name='test']/list",

'type': 'config',

'key': 'RANDOM-LETTERS',

'element': '<member>www.apitest1.com</member><member>www.apitest2.com</member><member>www.apitest3.com</member>'}

if I change the action from 'set' to 'delete', and element to 'element': '<member>www.apitest3.com</member>' it whacks the whole custom category

If I change the action from 'set' to 'edit' (and use the same element as above - only www.apitest3.com) I get the following error:

<response status="error" code="12"><msg><line>Edit breaks config validity</line></msg></response>

To delete multiple you can use an XPath with 'or':

[text()='foo' or text()='bar']

delete does not use an element argument, only xpath.

set is 'merge at XPath node', edit is 'replace at XPath node'.

for edit your example will need the member elements in <list></list>.

also see this:

  • 1 accepted solution
  • 3249 Views
  • 3 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!