You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@archiva.apache.org by Maury Hammel <mh...@vibehcm.com> on 2018/03/21 20:54:26 UTC

Problems with REST API getting artifacts.

Hello, I have just getting into Archiva and am having problems attempting to download artifacts using the REST API.  

I have the standalone distribution of Archiva 2.2.3 installed on CentOS 7 and have started it with the "archiva console" command.

As noted in the Quick Start guide, I can download an artifact using the following URL from the command line on the same machine:

% wget "http://localhost:8080/repository/internal/junit/junit/3.8.1/junit-3.8.1.jar"

My first attempt to down load the same artifact using the REST API generated a "403 Forbidden" error:

% wget "http://localhost:8080/restServices/archivaServices/searchService/artifact?g=junit&a=junit&v=3.8.1" -O junit-3.8.1.jar

After some reading, I went into conf/archiva.xml, changed rest.csrffilter.enabled to "false" and restarted Archiva.

Now when attempting the above command, I no longer get the "403 Forbidden" error, I get a "204 No Content" error and an empty file (see wget output below).

Is there something else (or something different) that I need to change in the Archiva configuration, or is my request formatted incorrectly?

Thanks in advance.....


--2018-03-21 14:53:33--  http://localhost:8080/restServices/archivaServices/searchService/artifact?g=junit&a=junit&v=3.8.1
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8080... connected.
HTTP request sent, awaiting response... 204 No Content
Length: 0
Saving to: 'junit-3.8.1.jar'

    [ <=>                                                                                     ] 0           --.-K/s   in 0s

2018-03-21 14:53:33 (0.00 B/s) - 'junit-3.8.1.jar' saved [0/0]


RE: Problems with REST API getting artifacts.

Posted by Maury Hammel <mh...@vibehcm.com>.
> Is anonymous access allowed to your repository?

I assumed it was by default, but I will check.  However, if anonymous access is not allowed, why would the non-REST API version of the query work?

> How many repositories do you have? Is it the same, if you set the repository ID with the 'r'-Parameter?

This is a fresh install, I have not set up any additional repositories.   Yes, I tried specifying the 'internal' repository with the r parameter, and there was no change in the result.

> Can you find the artifact on the web UI with the given entries?

Yes I can see the junit-3.8.1.jar artifact in the repository.
   
> Is there any info in the log file? If not, could you please change it to debug level, and send it to me?

Good point, I did not look there (dumb move).  I will check.  I have a couple of other high priority items that I need to address before I can get back to this, so it will probably not be until early next week that I can get that.

Thanks, again.

Maury

-----Original Message-----
From: Martin [mailto:martin_s@apache.org] 
Sent: March 24, 2018 1:45 PM
To: users@archiva.apache.org
Subject: Re: Problems with REST API getting artifacts.

Hello,

the 204 is thrown, if the artifact is not found by the search call. So I'm not sure, why it is not found.
Is anonymous access allowed to your repository? 
How many repositories do you have? Is it the same, if you set the repository ID with the 'r'-Parameter?
Can you find the artifact on the web UI with the given entries?

Is there any info in the log file? If not, could you please change it to debug level, and send it to me?

Greetings

Martin

Am Mittwoch, 21. März 2018, 21:54:26 CET schrieb Maury Hammel:
> Hello, I have just getting into Archiva and am having problems attempting to download artifacts using the REST API.  
> 
> I have the standalone distribution of Archiva 2.2.3 installed on CentOS 7 and have started it with the "archiva console" command.
> 
> As noted in the Quick Start guide, I can download an artifact using the following URL from the command line on the same machine:
> 
> % wget "http://localhost:8080/repository/internal/junit/junit/3.8.1/junit-3.8.1.jar"
> 
> My first attempt to down load the same artifact using the REST API generated a "403 Forbidden" error:
> 
> % wget 
> "http://localhost:8080/restServices/archivaServices/searchService/arti
> fact?g=junit&a=junit&v=3.8.1" -O junit-3.8.1.jar
> 
> After some reading, I went into conf/archiva.xml, changed rest.csrffilter.enabled to "false" and restarted Archiva.
> 
> Now when attempting the above command, I no longer get the "403 Forbidden" error, I get a "204 No Content" error and an empty file (see wget output below).
> 
> Is there something else (or something different) that I need to change in the Archiva configuration, or is my request formatted incorrectly?
> 
> Thanks in advance.....
> 
> 
> --2018-03-21 14:53:33--  
> http://localhost:8080/restServices/archivaServices/searchService/artif
> act?g=junit&a=junit&v=3.8.1 Resolving localhost (localhost)... ::1, 
> 127.0.0.1 Connecting to localhost (localhost)|::1|:8080... connected.
> HTTP request sent, awaiting response... 204 No Content
> Length: 0
> Saving to: 'junit-3.8.1.jar'
> 
>     [ <=>                                                                                     ] 0           --.-K/s   in 0s
> 
> 2018-03-21 14:53:33 (0.00 B/s) - 'junit-3.8.1.jar' saved [0/0]
> 
> 



Re: Problems with REST API getting artifacts.

Posted by Martin <ma...@apache.org>.
Hello,

the 204 is thrown, if the artifact is not found by the search call. So I'm not sure, why it is not found.
Is anonymous access allowed to your repository? 
How many repositories do you have? Is it the same, if you set the repository ID with the 'r'-Parameter?
Can you find the artifact on the web UI with the given entries?

Is there any info in the log file? If not, could you please change it to debug level, and send it to me?

Greetings

Martin

Am Mittwoch, 21. März 2018, 21:54:26 CET schrieb Maury Hammel:
> Hello, I have just getting into Archiva and am having problems attempting to download artifacts using the REST API.  
> 
> I have the standalone distribution of Archiva 2.2.3 installed on CentOS 7 and have started it with the "archiva console" command.
> 
> As noted in the Quick Start guide, I can download an artifact using the following URL from the command line on the same machine:
> 
> % wget "http://localhost:8080/repository/internal/junit/junit/3.8.1/junit-3.8.1.jar"
> 
> My first attempt to down load the same artifact using the REST API generated a "403 Forbidden" error:
> 
> % wget "http://localhost:8080/restServices/archivaServices/searchService/artifact?g=junit&a=junit&v=3.8.1" -O junit-3.8.1.jar
> 
> After some reading, I went into conf/archiva.xml, changed rest.csrffilter.enabled to "false" and restarted Archiva.
> 
> Now when attempting the above command, I no longer get the "403 Forbidden" error, I get a "204 No Content" error and an empty file (see wget output below).
> 
> Is there something else (or something different) that I need to change in the Archiva configuration, or is my request formatted incorrectly?
> 
> Thanks in advance.....
> 
> 
> --2018-03-21 14:53:33--  http://localhost:8080/restServices/archivaServices/searchService/artifact?g=junit&a=junit&v=3.8.1
> Resolving localhost (localhost)... ::1, 127.0.0.1
> Connecting to localhost (localhost)|::1|:8080... connected.
> HTTP request sent, awaiting response... 204 No Content
> Length: 0
> Saving to: 'junit-3.8.1.jar'
> 
>     [ <=>                                                                                     ] 0           --.-K/s   in 0s
> 
> 2018-03-21 14:53:33 (0.00 B/s) - 'junit-3.8.1.jar' saved [0/0]
> 
>