cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Former Member
Not applicable
Report Inappropriate Content
Message 1 of 13

Creating/Deleting/Modifying a Policy through the API

Jump to solution

Is there any way to create, delete, or modify policies through the API? I see that it is possible to import policies through an XML file in the API, but I was curious if there was something like policy.add or policy.delete, that functioned similarly to core.addUser or core.removeUser. Thank you.

2 Solutions

Accepted Solutions
cdinet
McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 4 of 13

Re: Creating/Deleting/Modifying a Policy through the API

Jump to solution

I ran this command - https://localhost:8443/remote/core.help?command=policy.importPolicy and got back that the file should be in the file:///c:/path to file format.  So it isn't dependent on it being python only.

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

View solution in original post

cdinet
McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 10 of 13

Re: Creating/Deleting/Modifying a Policy through the API

Jump to solution

I am not quite sure how to use the force.  For importing permission sets, this is the format - I would think it would be similar but I don't know if there is a space between -F and file or not.   I tested it a couple of ways, but for sure it didn't work with the @ symbol even without the -F.  I am not using curl, just the url in browser.

> curl -k -u ga:ga "https://localhost:8443/remote/core.importPermissionSets" -F file=@permissionSets.xml

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

View solution in original post

12 Replies
cdinet
McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 2 of 13

Re: Creating/Deleting/Modifying a Policy through the API

Jump to solution

No, only import/export, not modify.

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

Former Member
Not applicable
Report Inappropriate Content
Message 3 of 13

Re: Creating/Deleting/Modifying a Policy through the API

Jump to solution

Thank you. As a follow up question, when I try the policy.importPolicy command using a path like the following:

C:\Users\user\Documents\test.xml

I get an error that the file is not found and that it should be a fully qualified name. I saw an answer about putting file:/// in front of the path, but that seemed to be only for Python. Is this command possible through the command line? Thanks.

cdinet
McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 4 of 13

Re: Creating/Deleting/Modifying a Policy through the API

Jump to solution

I ran this command - https://localhost:8443/remote/core.help?command=policy.importPolicy and got back that the file should be in the file:///c:/path to file format.  So it isn't dependent on it being python only.

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

View solution in original post

Former Member
Not applicable
Report Inappropriate Content
Message 5 of 13

Re: Creating/Deleting/Modifying a Policy through the API

Jump to solution

I tried using that so that the overall format was something like

curl -k -u ga:ga "https://IP/remote/policy.importPolicy?file=file:///C:/Users/user/Documents/ePO/Test.xml"

but I still get the same error. Does that format look correct, or am I missing something?

 

If it helps, I'm using 4.6.6, which I know is well out of date and no longer supported, but it's what we're using currently. Thank you.

cdinet
McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 6 of 13

Re: Creating/Deleting/Modifying a Policy through the API

Jump to solution

I can't guarantee what would work or not with that version.  Regardless, I was wrong.  The help said "if you are using python..."  Let me test this out.

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

cdinet
McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 7 of 13

Re: Creating/Deleting/Modifying a Policy through the API

Jump to solution

Ok, I used policy.importPolicy?file=e:/My_Default.xml as my test.  The command and file name is case sensitive, so it has to match exact file name.

 

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

cdinet
McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 8 of 13

Re: Creating/Deleting/Modifying a Policy through the API

Jump to solution

You would need to use the force if there is already a policy by that name, as mine said 0 imported and 1 not overwritten.

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

Former Member
Not applicable
Report Inappropriate Content
Message 9 of 13

Re: Creating/Deleting/Modifying a Policy through the API

Jump to solution

I'm still getting the same error, even with force=true. Is it possible that there's a bug in 4.6.6 relating to this command?

cdinet
McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 10 of 13

Re: Creating/Deleting/Modifying a Policy through the API

Jump to solution

I am not quite sure how to use the force.  For importing permission sets, this is the format - I would think it would be similar but I don't know if there is a space between -F and file or not.   I tested it a couple of ways, but for sure it didn't work with the @ symbol even without the -F.  I am not using curl, just the url in browser.

> curl -k -u ga:ga "https://localhost:8443/remote/core.importPermissionSets" -F file=@permissionSets.xml

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

View solution in original post

You Deserve an Award
Don't forget, when your helpful posts earn a kudos or get accepted as a solution you can unlock perks and badges. Those aren't the only badges, either. How many can you collect? Click here to learn more.

Community Help Hub

    New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.

  • Find Forum FAQs
  • Learn How to Earn Badges
  • Ask for Help
Go to Community Help

Join the Community

    Thousands of customers use the McAfee Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

  • Get helpful solutions from McAfee experts.
  • Stay connected to product conversations that matter to you.
  • Participate in product groups led by McAfee employees.
Join the Community
Join the Community