Unable to add a new rule through PHP rest API

Hello,
I use the REST API : https://github.com/cloudflare/cloudflare-php

I try to update a firewall and add a new IP to an existing rule:

$expression = “(ip.src eq 100.100.100.100)”;
$firewall->updateFirewallRule($zoneid, $rule->id, $rule->filter->id, $expression , $options, ‘customNewRule’);

It does not work: the expression is not set to 100.100.100.100.
However the name of the rule is correctly changed to customNewRule, which means parameters and call is correct except the $newExpression.

When I manually paste that expression in my config panel, it is changed which means expression syntax is correct.

Do I need to encode $expression in base64 ? or some special encoding ?
I successfully did it with CURL -which is very unreadable - and I try to use the php rest API provided.

Any suggestion, ideas ?

I am using https://github.com/cloudflare/cloudflare-php

I try to update a firewall rule

$expression = "(ip.src eq 150.150.150.150);
$firewall->updateFirewallRule($zoneid, $rule->id, $rule->filter->id, $expression , $options, ‘newRule’);

Nothing changes, except the name of the rule newRule, which means parameters and call is correct

Do I need to encode $expression in base64 ? or some special encoding ?
I successfully did it with CURL -which is very unreadable - and I try to use the php rest API provided.

Any suggestion, ideas ?

Judging from the GitHub description, Firewall Rules is not covered by that SDK.

ok: maybe that is the reason.

However…
the function is well present in Firewall.php

public function updateFirewallRule(
string $zoneID,
string $ruleID,
string $filterID,
string $expression,
FirewallRuleOptions $options,
string $description = null,
int $priority = null
): \stdClass {

it allows to modify the rule name and I can see the PUT call in Guzzle.php

I “just” cannot modify the content of the rule. I am pretty sure it is implemented, but the string $description needs some extra or special encoding

Ok, I see that in the php file, and though Firewall Rules is relatively new, the file has been updated since the feature release.

That’s about all I’ve got, short of experimenting with it myself.

This topic was automatically closed after 30 days. New replies are no longer allowed.

I’ve finally experimented with this and found another post that pointed me to the fact that it’s the Filter you need to update, not the rule. A bit confusing, but it’s what worked:
https://developers.cloudflare.com/firewall/api/cf-filters/put