REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Evgeny Goldin
Hi,

When I try to use Spring 3 RestTemplate to call Artifactory REST API I always get 406 (Not Acceptable) even though I have Apache Commons HttpClient set with credentials. When I use HttpClient directly it works.

Is there anybody else who experienced similar issue with Spring 3 RestTemplate? I suspect it is buggy ..

Also, is there a way to configure Artifactory so that anonymous user can invoke any REST call without sending credentials? It didn't work for me even after I provided it a "delete" permissions.
I understand it is a security bridge but it would be nice to disable a "privileged user" REST requirement just for a while.

Thank you!

 
Best regards,
Evgeny
http://evgeny-goldin.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Evgeny Goldin
Also, from 3 password versions, which one can I send with REST calls?

* Plain text
* Encrypted password that can be stored in "settings.xml"
* MD5 of password that is available in the Admin => Advanced => Security Descriptor

Seems to me like the first two but I'd like to be sure.
Thank you!
Best regards,
Evgeny
http://evgeny-goldin.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Yoav  Landman
In reply to this post by Evgeny Goldin
On Mon, Jun 28, 2010 at 8:55 PM, Evgeny Goldin <[hidden email]> wrote:

Hi,

When I try to use Spring 3 RestTemplate to call Artifactory REST API I
always get 406 (Not Acceptable) even though I have Apache Commons HttpClient
set with credentials. When I use HttpClient directly it works.

Is there anybody else who experienced similar issue with Spring 3
RestTemplate? I suspect it is buggy ..

I believe the Spring queries set a content-type header that is not accepted by Artifactory's REST API and that's why you get a 406. Can you check with one method that fails and let us know which one and what was the content type value?
 

Also, is there a way to configure Artifactory so that anonymous user can
invoke any REST call without sending credentials? It didn't work for me even
after I provided it a "delete" permissions.
I understand it is a security bridge but it would be nice to disable a
"privileged user" REST requirement just for a while.

Are you trying to issue a DELETE query as anonymous? If you gave the anonymous user delete rights then it should work and it looks like a bug - feel free to open an issue. 


Thank you!



-----
Best regards,
Evgeny
http://evgeny-goldin.com/

--
View this message in context: http://forums.jfrog.org/REST-API-returns-406-Not-Acceptable-when-working-with-Spring-3-RestTemplate-tp5231906p5231906.html
Sent from the Artifactory - Users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Artifactory-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/artifactory-users




------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Artifactory-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/artifactory-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Yoav  Landman
In reply to this post by Evgeny Goldin
Your guess is good ;)
For encrypted password you need to have the password policy 'support' or 'require' encrypted password - note that in the later case you will not be able to send clear text.

On Mon, Jun 28, 2010 at 11:25 PM, Evgeny Goldin <[hidden email]> wrote:

Also, from 3 password versions, which one can I send with REST calls?

* Plain text
* Encrypted password that can be stored in "settings.xml"
* MD5 of password that is available in the Admin => Advanced => Security
Descriptor

Seems to me like the first two but I'd like to be sure.
Thank you!

-----
Best regards,
Evgeny
http://evgeny-goldin.com/

--
View this message in context: http://forums.jfrog.org/REST-API-returns-406-Not-Acceptable-when-working-with-Spring-3-RestTemplate-tp5231906p5232464.html
Sent from the Artifactory - Users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Artifactory-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/artifactory-users



------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Artifactory-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/artifactory-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Evgeny Goldin
In reply to this post by Yoav Landman
Yoav Landman-2 wrote
On Mon, Jun 28, 2010 at 8:55 PM, Evgeny Goldin <evgenyg@gmail.com> wrote:

I believe the Spring queries set a content-type header that is not accepted
by Artifactory's REST API and that's why you get a 406. Can you check with
one method that fails and let us know which one and what was the content
type value?
Ok, I'll check it tomorrow evening or day after tomorrow.

Yoav Landman-2 wrote
>
> Also, is there a way to configure Artifactory so that anonymous user can
> invoke any REST call without sending credentials? It didn't work for me
> even
> after I provided it a "delete" permissions.
> I understand it is a security bridge but it would be nice to disable a
> "privileged user" REST requirement just for a while.
>

Are you trying to issue a DELETE query as anonymous? If you gave the
anonymous user delete rights then it should work and it looks like a bug -
feel free to open an issue.
No, I was issuing a simple "/api/storage/{repoName}/{groupId}/{artifactId}" request to get a folder metadata, trying to see the latest version available. Yes, anonymous user has all rights, except "admin".
I'll check it again and will open a bug with a dump of HTTP headers.

Best regards,
Evgeny
http://evgeny-goldin.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Evgeny Goldin
In reply to this post by Yoav Landman
Just posted the credentials question to the Spring forum as well:
http://forum.springsource.org/showthread.php?t=91471
Best regards,
Evgeny
http://evgeny-goldin.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Yoav  Landman
The issue is most likely about wrong content-type - not bad credentials.

On Mon, Jun 28, 2010 at 11:49 PM, Evgeny Goldin <[hidden email]> wrote:

Just posted the credentials question to the Spring forum as well:
http://forum.springsource.org/showthread.php?t=91471

-----
Best regards,
Evgeny
http://evgeny-goldin.com/

--
View this message in context: http://forums.jfrog.org/REST-API-returns-406-Not-Acceptable-when-working-with-Spring-3-RestTemplate-tp5231906p5232566.html
Sent from the Artifactory - Users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Artifactory-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/artifactory-users




------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Artifactory-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/artifactory-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Evgeny Goldin
In reply to this post by Evgeny Goldin
Evgeny Goldin wrote
No, I was issuing a simple "/api/storage/{repoName}/{groupId}/{artifactId}" request to get a folder metadata, trying to see the latest version available. Yes, anonymous user has all rights, except "admin".
I'll check it again and will open a bug with a dump of HTTP headers.
Thinking about ti again .. I think I wasn't sending an anonymous request, I was sending credentialed request. I'll try again a pure anonymous one.
 
Best regards,
Evgeny
http://evgeny-goldin.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Evgeny Goldin
In reply to this post by Yoav Landman
The only diff between sending HTTP request with low-level HttpClient (that works) and using RestTemplate (that returns 406) I see now is that RestTemplate sends "Accept: text/plain, */*\r\n" while Http Client doesn't send this header. Will try to play with it ...
Best regards,
Evgeny
http://evgeny-goldin.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Evgeny Goldin
requestHeaders.set( "Accept", "*/*" ) ("application/json" didn't work)

This one works:

HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set( "Accept", "*/*" );
HttpEntity requestEntity = new HttpEntity( requestHeaders );

HttpEntity response = rest().exchange( url() + "/api/storage/{repoName}/{groupId}/{artifactId}",
                                       HttpMethod.GET,
                                       requestEntity,
                                       String.class,
                                       repoName(), serviceName, dataType );
String body = response.getBody();
Best regards,
Evgeny
http://evgeny-goldin.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Evgeny Goldin
And it had nothing to do with credentials, it works now without sending them at all, our "anonymous" user has permissions to do so.

I'll deals with credentials later
Best regards,
Evgeny
http://evgeny-goldin.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Yoav  Landman
Please track http://issues.jfrog.org/jira/browse/RTFACT-3330 which is about accepting application/json.

On Thu, Jul 1, 2010 at 6:00 PM, Evgeny Goldin <[hidden email]> wrote:

And it had nothing to do with credentials, it works now without sending them
at all, our "anonymous" user has permissions to do so.

I'll deals with credentials later

-----
Best regards,
Evgeny
http://evgeny-goldin.com/

--
View this message in context: http://forums.jfrog.org/REST-API-returns-406-Not-Acceptable-when-working-with-Spring-3-RestTemplate-tp5231906p5243694.html
Sent from the Artifactory - Users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Artifactory-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/artifactory-users




------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Artifactory-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/artifactory-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: REST API returns 406 (Not Acceptable) when working with Spring 3 RestTemplate

Evgeny Goldin
Ok, thank you!
Best regards,
Evgeny
http://evgeny-goldin.com/
Loading...