Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
PeterH
Participant
Jump to solution

set-automatic-purge with curl or curl_cli fail with error

curl_cli -s -k -H 'Content-Type: application/json' -H X-chkp-sid:"8ujfSl3KPfUi3iB_nMCjTnUz_fCa0buGpCtNdeQL7c4" https://x.x.x.x/set-automatic-purge -d '{"enabled":"true","keep-sessions-by-days":"true","number-of-sessions-to-keep":"30","scheduling.check-interval":"30","scheduling.time-units":"days","scheduling.start-date":"2022-09-05T16:46:00","number-of-days-to-keep":"14","keep-sessions-by-count":"false"}'
{
"code" : "generic_err_invalid_parameter_name",
"message" : "Unrecognized parameter [scheduling.check-interval]"

0 Kudos
1 Solution

Accepted Solutions
Bob_Zimmerman
Authority
Authority

The "scheduling.check-interval" syntax is a workaround for mgmt_cli. For a proper API call, 'scheduling' needs to contain an object, like this:

{
	"enabled":"true",
	"keep-sessions-by-days":"true",
	"number-of-sessions-to-keep":"30",
	"scheduling":{
		"check-interval":"30",
		"time-units":"days",
		"start-date":"2022-09-05T16:46:00"
	},
	"number-of-days-to-keep":"14",
	"keep-sessions-by-count":"false"
}

or as a single line:

{"enabled":"true","keep-sessions-by-days":"true","number-of-sessions-to-keep":"30","scheduling":{"check-interval":"30","time-units":"days","start-date":"2022-09-05T16:46:00"},"number-of-days-to-keep":"14","keep-sessions-by-count":"false"}

View solution in original post

0 Kudos
(1)
7 Replies
nmelay
Collaborator

I have no idea what's wrong, but this will not stop me from commenting!

Did you try it using mgmt_cli?
Using curl_cli for API calls is just... looking for trouble. 😛

What's your management's version?

You should probably not use "number-of-sessions-to-keep" with "keep-sessions-by-count":"false".
Actually, you should use "keep-sessions-by-count":"true" and "number-of-sessions-to-keep":"<some low number>" in order to always keep at least that much sessions.

You should use a shorter "scheduling.check-interval", like a day, or a weak max.
With your current setting, you'll keep anywhere from 14 to 44 days of changes, depending on the day of the month.

0 Kudos
nmelay
Collaborator

This seems to work fine here :

mgmt_cli -r true [-d domain] set automatic-purge enabled true keep-sessions-by-days true scheduling.check-interval 30 scheduling.time-units days scheduling.start-date now number-of-days-to-keep 14 keep-sessions-by-count false

0 Kudos
Bob_Zimmerman
Authority
Authority

The "scheduling.check-interval" syntax is a workaround for mgmt_cli. For a proper API call, 'scheduling' needs to contain an object, like this:

{
	"enabled":"true",
	"keep-sessions-by-days":"true",
	"number-of-sessions-to-keep":"30",
	"scheduling":{
		"check-interval":"30",
		"time-units":"days",
		"start-date":"2022-09-05T16:46:00"
	},
	"number-of-days-to-keep":"14",
	"keep-sessions-by-count":"false"
}

or as a single line:

{"enabled":"true","keep-sessions-by-days":"true","number-of-sessions-to-keep":"30","scheduling":{"check-interval":"30","time-units":"days","start-date":"2022-09-05T16:46:00"},"number-of-days-to-keep":"14","keep-sessions-by-count":"false"}
0 Kudos
(1)
PeterH
Participant

Hi Bob, many thanks.

With your syntax everything works well.

It looks like the API documentation is wrong.

0 Kudos
Bob_Zimmerman
Authority
Authority

The documentation is definitely correct. set automatic-purge was added in API version 1.6.1 (R80.40 jumbo 78 and up), and the 'scheduling' property has always said it needs an object.

mgmt_cli can't represent complex object and list graphs in its command line input, so it resorts to workarounds like "scheduling.check-interval 30" and "set access-rule source.add.1 <UUID>".

0 Kudos
PhoneBoy
Admin
Admin

The API documentation shows exactly what @Bob_Zimmerman says.
You have to look in the "Web Services" section of the documentation.
See: https://sc1.checkpoint.com/documents/latest/APIs/index.html#web/set-automatic-purge~v1.8%20 

0 Kudos
PeterH
Participant

The documentation show this:

Request

POST {{server}}/set-automatic-purge
Content-Type: application/json
X-chkp-sid: {{session}}

{
"enabled" : true,
"keep-sessions-by-days" : false,
"number-of-sessions-to-keep" : "10",
"scheduling.check-interval" : "21",
"scheduling.time-units" : "days",
"scheduling.start-date" : "2020-04-24T12:00:00"
}

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events