Hi,
I am doing an automated way to release multiple repositories in a "release-chain". In order to do that, I sometimes need to update the root POM and remove the "-SNAPSHOT" from the version, and then check in the file. As we use pull requests, and need to temporarily add the user as exempted from pull requests. And then I need to remove the user when the file is checked in. And here I get into problem. This is the curl command used to remove all exempted users:
curl -s -H 'Authorization: Bearer <token>' -H "Content-Type: application/json" -X POST -d '{"type": "pull-request-only","matcher":{"id":"refs/heads/master","displayId":"master","type":{"id":"BRANCH","name":"Branch"},"active": true}, "users": [''],"accessKeys": [197, 319]}' https://<host>/rest/branch-permissions/2.0/projects/AP/repos/pays-codegen/restrictions
Note the single quote in users array.
If I use double quote (i.e. ... "users": [""], ...), I get the error message:
{"errors":[{"context":"users","message":" is not a valid user"}]}
The problem is that I use a Python script and the requets.post() command, and it seems that requests automatically change single quote to double quote:
{'type': 'pull-request-only', 'matcher': {'id': 'refs/heads/master', 'displayId': 'master', 'type': {'id': 'BRANCH', 'name': 'Branch'}, 'active': 'true'}, 'users': [''], 'accessKeys': [197, 319]}
< POST /rest/branch-permissions/2.0/projects/ap/repos/pays-codegen/restrictions HTTP/1.1
< Host: bitbucket.shbmain.shb.biz
< User-Agent: python-requests/2.32.5
< Accept-Encoding: gzip, deflate
< Accept: application/json
< Connection: keep-alive
< Authorization: Bearer NzY5OTkyNTcyNjEyOrHQ6h7QVFAkrkMuNKmaBFiAqbyr
< Content-Type: application/json
< Content-Length: 195
<
< {"type": "pull-request-only", "matcher": {"id": "refs/heads/master", "displayId": "master", "type": {"id": "BRANCH", "name": "Branch"}, "active": "true"}, "users": [""], "accessKeys": [197, 319]}
(the first row is the payload. Here we see that the payload use single qoute: {'type': 'pull...}
In the last row, we see the debug printout from the actual REST call, and then all single quotes are replaced with double quotes, which for "users" is not good)
Found a solution.
Just using empty brackets will solve it, i.e.
... "users": [], ...
However, in the code it's not very ... pythonic ... not to be able to use a variable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.