Security

Reply
Frequent Contributor I
Posts: 62
Registered: ‎12-02-2014

Delete Endpoint via API

I am trying to delete a Endpoint from the Database via an API call.  We have several orphaned Endpoints (~2000) that exist and need deleted.  Can someone show me an example of how to do this with the API?  I was trying to do the following, but not successful.

 

 

To delete Endpoint with MAC Address = "00037f500001"

wget -q -O - --no-check-certificate --http-user=apiadmin --http-password=<password> https://10.238.32.32/tipsapi/config/delete/Endpoint/equals?macAddress=00037f500001

 

Thanks for the help.

Occasional Contributor I
Posts: 9
Registered: ‎01-22-2014

Re: Delete Endpoint via API

t
Frequent Contributor I
Posts: 62
Registered: ‎12-02-2014

Re: Delete Endpoint via API

pratikgadekar,

 

Not sure your post came through.  Can you repost?  Thanks.

MVP
Posts: 121
Registered: ‎07-13-2015

Re: Delete Endpoint via API

Hi, 

 

When using operations such as DELETE you mostly need to post it in JSON, which you can read in this guide : https://support.arubanetworks.com/Documentation/tabid/77/DMXModule/512/Command/Core_Download/Default.aspx?EntryId=14976

 

The ClearPass APIs are designed to expect the JSON content type when the API call requires a HTTP body to be submitted (typically in unsafe operations such as POST, PUT, PATCH and DELETE).

 

Unfortunately I don't have the complete string for you, but I hope this will help !

ACMP, ACCP, BCNE
Frequent Contributor I
Posts: 62
Registered: ‎12-02-2014

Re: Delete Endpoint via API

Thanks.  I have that doc, but am still unclear in the syntax of the curl command needed.

MVP
Posts: 121
Registered: ‎07-13-2015

Re: Delete Endpoint via API

[ Edited ]

Well that teased me and I ended up trying to achieve it. Wasn't able to do it with JSON. The "API Explorer" in clearpass doesn't have any Endpoint section neither and documentation isn't talking much about it. When I try it with cURL + XML, I always end up with 403 Access Forbidden error message.

Still I have a solution for you :D

 

You could tag your Orphaned endpoints with an attribute and then go within the Endpoint tab in clearpass and filter them based on that Attribute, then simply delete them all using the select all checkbox.

 

First create a new attribute (let's call it Orphaned) :

 

orph.png


You can use the following cURL code to add an attribute to an Endpoint (You would need to set-up a script to automate MAC entries in the list or use Notepad++)

 

curl -sk -o - -u apiadmin:YOUR_PASSWORD -d '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TipsApiRequest xmlns="http://www.avendasys.com/tipsapiDefs/1.0">
<TipsHeader version="3.0"/>
<Endpoints>
<Endpoint status="Known" macAddress="YOUR_MAC">
<EndpointTags tagName="Orphaned" tagValue="True"/>
</Endpoint>
</Endpoints>
</TipsApiRequest>' https://YOUR_CLEARPASS_IP/tipsapi/config/write/Endpoint

Then, simply add a filter like this :

Filter.png

 

Should save you some time :)

ACMP, ACCP, BCNE
Frequent Contributor I
Posts: 62
Registered: ‎12-02-2014

Re: Delete Endpoint via API

Overclock,

 

That is a great idea.  I did open a Support Case today and asking for help on it.  If they give me an answer I will post it here.

 

I agree the API documentation is lacking.  I am not clear what options I even have to work with.

MVP
Posts: 121
Registered: ‎07-13-2015

Re: Delete Endpoint via API

Thank you, yes please let me know if they find a way ;)

ACMP, ACCP, BCNE
Aruba Employee
Posts: 30
Registered: ‎09-10-2012

Re: Delete Endpoint via API

Mark,

 

The ClearPass API configuration guide has the information to handle the guest user accounts. Followed the same for endpoints with appropriate tags and got it working.

 

Deleting endpoint using tips-api requires two steps.

 

1.Do deleteConfirm to fetch the identifier(element_id).

2.And then delete the endpoint using the returned identifier.

 

Refer the below examples,

 

Post the request to https://<cppm_ip>/tipsapi/config/deleteConfirm/Endpoint

 

curl -sk -o - -u apiadmin:<password> -d '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<TipsApiRequest xmlns="http://www.avendasys.com/tipsapiDefs/1.0">
<TipsHeader version="6.4"/>
<Filter entity="Endpoint">
<Criteria fieldName="macAddress" filterString="112233445566" match="contains"/>
</Filter>
</TipsApiRequest>'

 

Response will look like,

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><TipsApiResponse xmlns="http://www.avendasys.com/tipsapiDefs/1.0"><TipsHeader exportTime="Fri Feb 05 16:56:44 IST 2016" version="6.4"/><StatusdCount>1</EntityMaxRecordCount><Endpoints><Endpoint macAddress="112233445566" status="Unknown"><element-id>Endpoint_112233445566_s7m</element-id></Endpoint></Endpoints></TipsApiResponse>

 

Use the returned element id and Post the delete request to https://<cppm_ip>/tipsapi/config/delete/Endpoint

 

curl -sk -o - -u apiadmin:<password> -d '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<TipsApiRequest xmlns="http://www.avendasys.com/tipsapiDefs/1.0">
<TipsHeader version="6.4"/>
<Delete>
<Element-Id>Endpoint_112233445566_s7m</Element-Id>
</Delete>
</TipsApiRequest>'

 

Response will look like,

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<TipsApiResponse xmlns="http://www.avendasys.com/tipsapiDefs/1.0">

<TipsHeader exportTime="Fri Feb 05 17:13:24 IST 2016" version="6.4"/><StatusCode>Success</StatusCode>

<LogMessages>

<Message>Endpoint deleted successfully</Message>

</LogMessages>

</TipsApiResponse>

 

 

 

Thank you,
Saravanan Rajagopal


**Did something you read in the Community solve a problem for you? If so, click "Accept as Solution" in the bottom right hand corner of the post.
MVP
Posts: 121
Registered: ‎07-13-2015

Re: Delete Endpoint via API

I get the element id but then I launch the following :

 

curl -sk -o - -u apiadmin:mypassword -d '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<TipsApiRequest xmlns="http://www.avendasys.com/tipsapiDefs/1.0">

<TipsHeader version="6.4"/>

<Delete>

<Element-Id>Endpoint_MYMAC_Mrx</Element-Id>

</Delete>

</TipsApiRequest>' https://MYCPPMIP/tipsapi/config/delete/Endpoint

 

and I get this response : This request requires HTTP authentication.

 

 

ACMP, ACCP, BCNE
Search Airheads
Showing results for 
Search instead for 
Did you mean: