Update member API not working - "Invalid Roles"

I am trying to replicate the code posted at Cloudflare API Documentation and I keep getting the error: “Invalid request: Invalid roles”.

I used the exact code posted on that page (with my email and auth key and correct identifiers, ofc) and I got the error string:

{“success”:false,“errors”:[{“code”:1001,“message”:“Invalid request: Invalid roles”}],“messages”:,“result”:null}%

I used DELETE instead of PUT and was able to remove the account so I know it isn’t a permission or access issue.

Can someone please assist? Are we able to define custom roles this way or are we supposed to reference the IDs of the regular role list (which I have also tried but recieved the same error)

Did you ever find a resolution for this issue?

The answer is “No, we are not able to define custom roles this way”. We nee dto reference the ID of the regular role list. This is the format I used (using PHP):

curl_setopt($ch, CURLOPT_URL, ‘https://api.cloudflare.com/client/v4/accounts/(account id)/members/(userid)’);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘PUT’);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$data = ‘{“roles”: [{“id”:“(role id)”}]}’;

1 Like