Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding collaborator to project via QFieldcloud REST API #536

Open
chleeb opened this issue Mar 4, 2023 · 1 comment
Open

Adding collaborator to project via QFieldcloud REST API #536

chleeb opened this issue Mar 4, 2023 · 1 comment

Comments

@chleeb
Copy link

chleeb commented Mar 4, 2023

As this might be a bug or at least a mistake in the documantation, I created an issue out of the discussion.

Best,
Christoph

Discussed in opengisch/QField#3931

Originally posted by chleeb February 20, 2023
Hi,

I wanted to use the QFieldcloud REST API to add an collaborator to an existing QField project in the QField cloud.

Following the documentation (https://docs.qfield.org/reference/qfieldcloud/api/) a data package

{
  "role": "string"
}

is submitted as POST request via api/v1/collaborators/{projectid}/.

However, I wondered if this can be correct as no user name is submitted together with the role.

I tried to implement the POST request into a python script:

response_login = requests.request(
               method = "POST",
               url = "https://app.qfield.cloud/api/v1/auth/login/",
               data = {'username': 'USERNAME', 'password': 'PASSWORD'} )
payload = response_login.json()

response_add_collaborator = requests.request(
               method = "POST",
               url = "https://app.qfield.cloud/api/v1/collaborators/PROJECT_ID/",
               headers = {'Authorization': 'token ' + payload["token"], 'User-Agent': 'sdk|py|0.6.1 python-requests|2.28.2'},
               data = {"role": "editor"})

print(response_add_collaborator)
print(response_add_collaborator.json())

what results in

<Response [500]>
{'code': 'unknown_error', 'message': 'QFieldcloud Unknown Error'}

I then played around and added a collaborator in the data package:

data = {"collaborator": "USER", "role": "editor"})

and got:

<Response [400]>
{'code': 'validation_error', 'message': 'Validation error'}

Has anyone an idea how to add a collaborator to a project via the API?

Thanks,
Christoph

@suricactus suricactus transferred this issue from opengisch/QField Mar 4, 2023
@suricactus
Copy link
Collaborator

Hey, @chleeb . Thanks for the report. We do not use this API endpoint on QField, QFieldSync and qfield.cloud anymore, which might explain why we never caught it was broken. Just not to give you false expectations, it will not be in our priority bugfix queue for the upcoming months. Actually we were considering internally to deprecate it. If you rely on this functionality, I am open to keep it, but feel free to send us an email on sales@qfield.cloud or open a PR fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants