Get Content REST API returns 404 (Not Found)

351 views
Skip to first unread message

praveenm

unread,
Jan 5, 2018, 7:03:59 AM1/5/18
to Repo and Gerrit Discussion
Dear All,

We are trying to fetch the content of a file using the below Gerrrit REST API.

Get Content

'GET /projects/{project-name}/branches/{branch-id}/files/{file-id}/content'

Gets the content of a file from the HEAD revision of a certain branch.

Always  it returns 404 not found,

Anybody has tried this , Please help us.

Thanks in advance.


Edwin Kempin

unread,
Jan 5, 2018, 7:06:25 AM1/5/18
to praveenm, Repo and Gerrit Discussion
Did you include the /a prefix to trigger authentication?
 

Thanks in advance.


--
--
To unsubscribe, email repo-discuss+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

praveenm mulimani

unread,
Jan 5, 2018, 7:10:41 AM1/5/18
to Edwin Kempin, Repo and Gerrit Discussion
Yes, we have included
--
Praveen M
9986069592

Edwin Kempin

unread,
Jan 5, 2018, 7:12:08 AM1/5/18
to praveenm mulimani, Repo and Gerrit Discussion
Did you URL-encode the file name?

praveenm mulimani

unread,
Jan 5, 2018, 7:24:12 AM1/5/18
to Edwin Kempin, Repo and Gerrit Discussion
yes


URL is constructed as per below

{project-name} = 'platform%2Fvendor%2ex.git'
{branch-id}= 'test_master'
{file-id} = 'java%2Frvi%2Fabcd%2Fconfiguration.a.xml'
Replaced ’/’ with %2F

gerrit_url/a/projects/platform%2Fvendor%2ex.git/branches/test_master/files/java%2Frvi%2Fabcd%2Fconfiguration.a.xml/content

--
Praveen M
9986069592

Edwin Kempin

unread,
Jan 5, 2018, 7:28:56 AM1/5/18
to praveenm mulimani, Repo and Gerrit Discussion
On Fri, Jan 5, 2018 at 1:24 PM, praveenm mulimani <praveen....@gmail.com> wrote:
yes


URL is constructed as per below

{project-name} = 'platform%2Fvendor%2ex.git'
{branch-id}= 'test_master'
{file-id} = 'java%2Frvi%2Fabcd%2Fconfiguration.a.xml'
Replaced ’/’ with %2F

gerrit_url/a/projects/platform%2Fvendor%2ex.git/branches/test_master/files/java%2Frvi%2Fabcd%2Fconfiguration.a.xml/content

Try the project name without ".git" extension. 

If this doesn't help try if the following work to narrow down the problem:

1. gerrit_url/a/projects/
2. gerrit_url/a/projects/<project>/
3. gerrit_url/a/projects/<project>/branches/
4. gerrit_url/a/projects/<project>/branches/<branch-name>

praveenm mulimani

unread,
Jan 5, 2018, 7:31:50 AM1/5/18
to Edwin Kempin, Repo and Gerrit Discussion
sorry its an example ,

we have tried it does not work 
--
Praveen M
9986069592

Edwin Kempin

unread,
Jan 5, 2018, 7:34:23 AM1/5/18
to praveenm mulimani, Repo and Gerrit Discussion
On Fri, Jan 5, 2018 at 1:31 PM, praveenm mulimani <praveen....@gmail.com> wrote:
sorry its an example ,

we have tried it does not work 

On Fri, Jan 5, 2018 at 5:58 PM, Edwin Kempin <eke...@google.com> wrote:


On Fri, Jan 5, 2018 at 1:24 PM, praveenm mulimani <praveen....@gmail.com> wrote:
yes


URL is constructed as per below

{project-name} = 'platform%2Fvendor%2ex.git'
{branch-id}= 'test_master'
{file-id} = 'java%2Frvi%2Fabcd%2Fconfiguration.a.xml'
Replaced ’/’ with %2F

gerrit_url/a/projects/platform%2Fvendor%2ex.git/branches/test_master/files/java%2Frvi%2Fabcd%2Fconfiguration.a.xml/content

Try the project name without ".git" extension. 

If this doesn't help try if the following work to narrow down the problem:

1. gerrit_url/a/projects/
2. gerrit_url/a/projects/<project>/
3. gerrit_url/a/projects/<project>/branches/
4. gerrit_url/a/projects/<project>/branches/<branch-name>
But all of these do work?

praveenm mulimani

unread,
Jan 5, 2018, 7:35:53 AM1/5/18
to Edwin Kempin, Repo and Gerrit Discussion
We have tried

Get Branch

'GET /projects/{project-name}/branches/{branch-id}'

it is working.


issue is if we add {file-id} = 'java%2Frvi%2Fabcd%2Fconfiguration.a.xml' it is returning 404 error


--
Praveen M
9986069592

Edwin Kempin

unread,
Jan 5, 2018, 7:44:07 AM1/5/18
to praveenm mulimani, Repo and Gerrit Discussion
Sorry, then I don't know. This REST endpoint works for me.

Maybe try it with a file in the root of a project so that encoding the file name is not required?
Something like: 
  
gerrit_url/a/projects/<project>/branches/<branch-name>/files/test.txt/content

syeds...@gmail.com

unread,
Jan 8, 2018, 2:25:24 AM1/8/18
to Repo and Gerrit Discussion
Access to file in the root of a project is also not working. Is there any user privilege stetting required? Could you please suggest any other means to download latest file from gerrit project through REST API.
Requirement is file needs to be downloaded given a project name & Branch.

Thanks for your help.
Yes, we have included

 

Thanks in advance.


--
--
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.

For more options, visit https://groups.google.com/d/optout.




--
Praveen M
9986069592




--
Praveen M
9986069592




--
Praveen M
9986069592



--
Praveen M
9986069592

Reply all
Reply to author
Forward
0 new messages