0

I'm currently trying to use a RestAPI to set user permissions via a python script. It reads the permission from one server and has to import the permissions of a the same user on another server. I am using the python requests module and did read up on how to use put with parameters but appear to have issues with the correct syntax.

RestAPI endpoint

the username and permission part is what causes my issue.

I have tried like this:

#!/usr/bin/env python
import requests
payload = (({username}), ({permission}))
set_user_permission_project = requests.put(f'{url}/rest/api/1.0/projects/{row[2]}/permissions/users', auth=(user, pw), params=payload)

And prior to that attempt, I tried it like this:

#!/usr/bin/env python
import requests
set_user_permission_project = requests.put(f'{url}/rest/api/1.0/projects/{row[2]}/permissions/users?{username}&{row[8]}', auth=(user, pw))

Probably I am missing something very essential here and don't get it.

Thanks a lot in advance for your help

Br

4

1 回答 1

1

在@estherwn 非常有用的评论之后,我仔细检查了 RestAPI 并相应地调整了调用。正如建议的那样,它应该是 key+var 。因此,我的答案是:

import requests set_user_permission_project = requests.put(f'{url}/rest/api/1.0/projects/{row[2]}/permissions/users?name={username}&permission={row[8]}', auth=(user, pw))

我希望有一天有人会发现这很有帮助。再次感谢您的帮助@estherwn

于 2020-05-25T13:12:17.653 回答