Set Assignee

116 views
Skip to first unread message

William

unread,
Sep 15, 2021, 2:41:02 PM9/15/21
to Repo and Gerrit Discussion

Matthias Sohn

unread,
Sep 15, 2021, 5:36:39 PM9/15/21
to William, Repo and Gerrit Discussion
use curl to call this REST API ? 

William

unread,
Sep 15, 2021, 10:47:11 PM9/15/21
to Repo and Gerrit Discussion
I tried as curl -u username:password -d '{"assignee":"assigneename"}' "https://company.com/changes/projectname~branchname~change-id/assignee"

I get the error "Authentication required"

Nasser Grainawi

unread,
Sep 15, 2021, 11:46:50 PM9/15/21
to William, Repo and Gerrit Discussion

On Sep 15, 2021, at 8:47 PM, William <bacha....@gmail.com> wrote:

Please don’t top post, it makes discussions harder to follow.


I tried as curl -u username:password -d '{"assignee":"assigneename"}' "https://company.com/changes/projectname~branchname~change-id/assignee"

I get the error "Authentication required"

It looks like you probably didn’t use the authenticated URL. See https://gerrit-review.googlesource.com/Documentation/rest-api.html#authentication

Nasser


On Wednesday, September 15, 2021 at 2:36:39 PM UTC-7 Matthias Sohn wrote:
On Wed, Sep 15, 2021 at 8:41 PM William <bacha....@gmail.com> wrote:
use curl to call this REST API ? 

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/18c9f392-71c5-49ea-9641-b0a69bba104bn%40googlegroups.com.

Message has been deleted

William

unread,
Sep 16, 2021, 1:18:38 AM9/16/21
to Repo and Gerrit Discussion
On Wednesday, September 15, 2021 at 8:46:50 PM UTC-7 nas...@codeaurora.org wrote:

On Sep 15, 2021, at 8:47 PM, William <bacha....@gmail.com> wrote:

Please don’t top post, it makes discussions harder to follow.


I tried as curl -u username:password -d '{"assignee":"assigneename"}' "https://company.com/changes/projectname~branchname~change-id/assignee"

I get the error "Authentication required"

It looks like you probably didn’t use the authenticated URL. See https://gerrit-review.googlesource.com/Documentation/rest-api.html#authentication

Nasser

I added /a/ and tried as below,now I get "unauthorized" error,I am pretty sure the username and password or accurate

curl -u username:password -d '{"assignee":"assigneename"}' "https://company.com/a/changes/projectname~branchname~change-id/assignee

Sven Selberg

unread,
Sep 16, 2021, 3:11:29 AM9/16/21
to Repo and Gerrit Discussion
On Thursday, September 16, 2021 at 7:18:38 AM UTC+2 William wrote:
On Wednesday, September 15, 2021 at 8:46:50 PM UTC-7 nas...@codeaurora.org wrote:

On Sep 15, 2021, at 8:47 PM, William <bacha....@gmail.com> wrote:

Please don’t top post, it makes discussions harder to follow.


I tried as curl -u username:password -d '{"assignee":"assigneename"}' "https://company.com/changes/projectname~branchname~change-id/assignee"

I get the error "Authentication required"

It looks like you probably didn’t use the authenticated URL. See https://gerrit-review.googlesource.com/Documentation/rest-api.html#authentication

Nasser

I added /a/ and tried as below,now I get "unauthorized" error,I am pretty sure the username and password or accurate

curl -u username:password -d '{"assignee":"assigneename"}' "https://company.com/a/changes/projectname~branchname~change-id/assignee

To set assignee you'll need to use POST.

Check if the account you are curl:ing with is allowed to see the change:
 curl  -XGET -u username:password "https://company.com/a/changes/projectname~branchname~change-id"

If you can see the change, make sure you are allowed to edit assignee for that change:
https://gerrit-documentation.storage.googleapis.com/Documentation/3.3.6/access-control.html#category_edit_assigned_to

William

unread,
Sep 17, 2021, 2:08:53 PM9/17/21
to Repo and Gerrit Discussion
On Thursday, September 16, 2021 at 12:11:29 AM UTC-7 Sven Selberg wrote:
On Thursday, September 16, 2021 at 7:18:38 AM UTC+2 William wrote:
On Wednesday, September 15, 2021 at 8:46:50 PM UTC-7 nas...@codeaurora.org wrote:

On Sep 15, 2021, at 8:47 PM, William <bacha....@gmail.com> wrote:

Please don’t top post, it makes discussions harder to follow.


I tried as curl -u username:password -d '{"assignee":"assigneename"}' "https://company.com/changes/projectname~branchname~change-id/assignee"

I get the error "Authentication required"

It looks like you probably didn’t use the authenticated URL. See https://gerrit-review.googlesource.com/Documentation/rest-api.html#authentication

Nasser

I added /a/ and tried as below,now I get "unauthorized" error,I am pretty sure the username and password or accurate

curl -u username:password -d '{"assignee":"assigneename"}' "https://company.com/a/changes/projectname~branchname~change-id/assignee

To set assignee you'll need to use POST.

Check if the account you are curl:ing with is allowed to see the change:
 curl  -XGET -u username:password "https://company.com/a/changes/projectname~branchname~change-id"

Strangely when I access  "https://company.com/a/changes/projectname~branchname~change-id" on a web browser ,it downloads the .json file
When I do a "curl  -XGET -u username:password "https://company.com/a/changes/projectname~branchname~change-id" I get an "Unauthorized" error

I logged with the same user on the web browser, confused as to what is wrong with the curl command?

Nasser Grainawi

unread,
Sep 17, 2021, 3:42:43 PM9/17/21
to William, Repo and Gerrit Discussion
You’ll want to double check that the username and password you’re using with cURL matches Gerrit’s settings. That info will be in your settings (url might be different depending on your Gerrit version): https://company.com/settings/#HTTPCredentials



-- 
-- 
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

--- 
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.

William

unread,
Sep 17, 2021, 7:48:33 PM9/17/21
to Repo and Gerrit Discussion
On Friday, September 17, 2021 at 12:42:43 PM UTC-7 nas...@codeaurora.org wrote:

You’ll want to double check that the username and password you’re using with cURL matches Gerrit’s settings. That info will be in your settings (url might be different depending on your Gerrit version): https://company.com/settings/#HTTPCredentials
Perfect, this link ,I was using a different pasword, we are supposed to use the HTTP password generated at this link 

William

unread,
Sep 17, 2021, 8:21:18 PM9/17/21
to Repo and Gerrit Discussion
On Friday, September 17, 2021 at 4:48:33 PM UTC-7 William wrote:
On Friday, September 17, 2021 at 12:42:43 PM UTC-7 nas...@codeaurora.org wrote:

You’ll want to double check that the username and password you’re using with cURL matches Gerrit’s settings. That info will be in your settings (url might be different depending on your Gerrit version): https://company.com/settings/#HTTPCredentials
Perfect, this link ,I was using a different pasword, we are supposed to use the HTTP password generated at this link 

Now ,I get the error "assignee does not identify a registered user", I am trying to assign as  { "assignee": "jdoe" }  and I can confirm jdoe is a registered user and am able to manually assign this from the UI

Sven Selberg

unread,
Sep 20, 2021, 3:21:47 AM9/20/21
to Repo and Gerrit Discussion
What Gerrit is saying is that it can't find any user by the name of "assignee".
Which suggests that something is not right with your request.
 

William

unread,
Sep 20, 2021, 8:26:16 PM9/20/21
to Repo and Gerrit Discussion
On Monday, September 20, 2021 at 12:21:47 AM UTC-7 Sven Selberg wrote:
Now ,I get the error "assignee does not identify a registered user", I am trying to assign as  { "assignee": "jdoe" }  and I can confirm jdoe is a registered user and am able to manually assign this from the UI

What Gerrit is saying is that it can't find any user by the name of "assignee".
Which suggests that something is not right with your request.

I am trying send a python put as below using https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#set-assignee ,any guidance on why am getting "assignee does not identify a registered user" ?

import requests
from requests.auth import HTTPBasicAuth

mydata = {"assignee": "assigneename"}
            data=mydata,                         
            auth=('username', 'password'),
            headers={'Content-type':'application/json'},
             )
print (response.text) 
 

Björn Pedersen

unread,
Sep 21, 2021, 2:28:56 AM9/21/21
to Repo and Gerrit Discussion
Did you try it with the email address ( that is what most other user-setting api endpoints use)? If that works, it would be a documentation error.

Björn

Sven Selberg

unread,
Sep 21, 2021, 3:23:46 AM9/21/21
to Repo and Gerrit Discussion
Surely this isn't an exact copy of your code.
The error message suggests that "mydata" looks like {"assignee":"assignee"}, I'd check what mydata contains before request.put is called.
 
 

Björn Pedersen

unread,
Sep 21, 2021, 4:09:23 AM9/21/21
to Repo and Gerrit Discussion
Seems like a doc and/or impl. problem.

I can reproduce the error. If I set data to just:
  
    data = 'assigneename'


then the call succeeds. So it seems the endpoint does not expect an array, but just a plain string....


Björn
 
 

Sven Selberg

unread,
Sep 21, 2021, 4:44:17 AM9/21/21
to Repo and Gerrit Discussion
On Tuesday, September 21, 2021 at 10:09:23 AM UTC+2 ice...@googlemail.com wrote:
Sven Selberg schrieb am Dienstag, 21. September 2021 um 09:23:46 UTC+2:
On Tuesday, September 21, 2021 at 2:26:16 AM UTC+2 William wrote:
On Monday, September 20, 2021 at 12:21:47 AM UTC-7 Sven Selberg wrote:
Now ,I get the error "assignee does not identify a registered user", I am trying to assign as  { "assignee": "jdoe" }  and I can confirm jdoe is a registered user and am able to manually assign this from the UI

What Gerrit is saying is that it can't find any user by the name of "assignee".
Which suggests that something is not right with your request.

I am trying send a python put as below using https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#set-assignee ,any guidance on why am getting "assignee does not identify a registered user" ?

import requests
from requests.auth import HTTPBasicAuth

mydata = {"assignee": "assigneename"}
            data=mydata,                         
            auth=('username', 'password'),
            headers={'Content-type':'application/json'},
             )
print (response.text) 

It's been a while since I worked with requests but I believe you should pass a json-string as data so it should be:

import json
...

            data=json.dumps(mydata),                         
            auth=('username', 'password'),
            headers={'Content-type':'application/json'},
             )
Surely this isn't an exact copy of your code.
The error message suggests that "mydata" looks like {"assignee":"assignee"}, I'd check what mydata contains before request.put is called.
 

Björn Pedersen

unread,
Sep 21, 2021, 10:09:25 AM9/21/21
to Repo and Gerrit Discussion
or:
requests.put ( url, json=mydata, auth =....)

Sven Selberg

unread,
Sep 21, 2021, 10:43:38 AM9/21/21
to Repo and Gerrit Discussion
Yes, that's it!

William

unread,
Sep 22, 2021, 12:28:54 PM9/22/21
to Repo and Gerrit Discussion
Yup, that worked.Thanks all 
Reply all
Reply to author
Forward
0 new messages