cancel
Showing results for 
Search instead for 
Did you mean: 
antnee777
Level 7

I need a REST....

Jump to solution

Hello,

I am testing pushing a ruleset via REST, for my test I created a top level ruleset with nothing inside it and exported it to blank.xml (see below)

I try to push the ruleset like this, expecting it to land in the default position (-1). Note that I don't use the '@' sign in front of the xml file name, as the REST documentation tells me not to (or rather the example of this in the REST docs does not use the '@' sign.

`curl -i -b cookies.txt -X POST -d blank.xml -H "Content-Type: application/xml" "$REST/rulesets/import" --insecure`

The error thrown is "XMLFormat wrong, or invalid content length", which is a puzzle, as the XML I use is exported from the MWG.

Can anyone spot my error and enlighten me ?

For completeness, if I do include '@' like this:

`curl -i -b cookies.txt -X POST -d @blank.xml -H "Content-Type: application/xml" "$REST/rulesets/import" --insecure`

The error thrown is "Internal Server Error"

<From the REST Docs>

Imports a ruleset to the given position 

 curl -i -b cookies.txt -X POST -d rulesetInMWGLibraryXMLForm.xml -H "Content-Type: application/xml" "$REST/rulesets/import" 

blank.xml

<libraryContent>

  <libraryObject>

    <name>newblank</name>

    <version>7.5.1-18935</version>

    <description></description>

  </libraryObject>

  <ruleGroup id="347" defaultRights="2" name="newblank" enabled="true" cycleRequest="true" cycleResponse="true" cycleEmbeddedObject="true" cloudSynced="false">

    <acElements/>

    <condition always="true">

      <expressions/>

    </condition>

    <description></description>

    <rules/>

    <ruleGroups/>

  </ruleGroup>

</libraryContent>

, I'm sure you can help

0 Kudos
1 Solution

Accepted Solutions
McAfee Employee

Re: Re: I need a REST....

Jump to solution

Hi Ant,

So in my quick testing, you need the @.

So the command is:


curl -i -b cookies.txt -X POST -d @blank.xml -H "Content-Type: application/xml" "$REST/rulesets/import"


I got the internal error if I try to import the same ruleset again (because of duplicate toplevel ruleset names.

Best Regards,

Jon

0 Kudos
9 Replies
McAfee Employee

Re: I need a REST....

Jump to solution

Im looking as well

McAfee Employee

Re: Re: I need a REST....

Jump to solution

Hi Ant,

So in my quick testing, you need the @.

So the command is:


curl -i -b cookies.txt -X POST -d @blank.xml -H "Content-Type: application/xml" "$REST/rulesets/import"


I got the internal error if I try to import the same ruleset again (because of duplicate toplevel ruleset names.

Best Regards,

Jon

0 Kudos
eelsasser
Level 15

Re: Re: Re: I need a REST....

Jump to solution

And you need a commit command to save the changes.


curl -i -c cookies.txt -H "Authorization: Basic YmxhaDpibGFo" -X POST "$REST/login"


curl -i -b cookies.txt -X POST -d @Blank.xml -H "Content-Type: application/xml" "$REST/rulesets/import?position=0"


curl -i -b cookies.txt -X POST "$REST/commit"


curl -i -b cookies.txt -X POST "$REST/logout"


0 Kudos
antnee777
Level 7

Re: I need a REST....

Jump to solution

Thanks Eric, and understood, but I was holding off on the commit until I got a good response code back from my push

0 Kudos
McAfee Employee

Re: Re: I need a REST....

Jump to solution

What if you delete the existing ruleset with the same name?

antnee777
Level 7

Re: I need a REST....

Jump to solution

yes that works.

So all I need to know is why MWG thought that a ruleset named "blank" was a duplicate of "newblank", assume an internal ruleset id, but I thought that would be reindexed on the import ?

0 Kudos
McAfee Employee

Re: Re: I need a REST....

Jump to solution

Hi Ant,

It seems to do it when you load it from the UI (the java applet), but not over REST.

Not sure if it's by design or not, I'll check.

Best Regards,

Jon

0 Kudos
antnee777
Level 7

Re: I need a REST....

Jump to solution

Thanks Jon, please let me know, otherwise I am limited to only being able to import rulesets which I have created and then deleted in the UI, which seems a bit counter productive ....

0 Kudos
antnee777
Level 7

Re: I need a REST....

Jump to solution

Hi Jon, I edited the ruleset (search and replace blank with newblank), I still get "internal server error" when I try to push.

0 Kudos