Artifactory - Tomcat errors when making REST calls
Question: I am trying to perform certain actions against my Artifactory instance using
the REST API, but when I make certain calls I get the following Tomcat error:

    
    
    HTTP Status 404
    The requested resource is not available.
    

I'm doing this using a Python script and my Artifactory instance is v4.2.2 rev
40049 deployed using an RPM package via these
[instructions](https://www.jfrog.com/confluence/display/RTF/Installing+on+Linux+Solaris+or+Mac+OS#InstallingonLinuxSolarisorMacOS-
RPMorDebianInstallation).

The problem only seems to happen when I made certain REST calls that use the
`api/` URI vs the `artifactory/` URI. Here are some examples of what I mean:

I can successfully deploy an artifact using this command:

    
    
    >>import requests
    >>session = requests.session()
    >>response = session.put('http://artifactory.domain.com/artifactory/repo/test.txt')
    

Response:

    
    
    >>response.status_code
    201
    >>response.text
    u'{\n  "repo" : "repo",\n  "path" : "/",\n  "created" : "2015-11-17T12:10:12.679-07:00",\n  "createdBy" : "anonymous",\n  "downloadUri" : "http://artifactory.domain.com:8081/artifactory/repo/test.txt",\n  "mimeType" : "application/octet-stream",\n  "size" : "0",\n  "checksums" : {\n    "sha1" : "da39a3ee5e6b4b0d3255bfef95601890afd80709",\n    "md5" : "d41d8cd98f00b204e9800998ecf8427e"\n  },\n  "originalChecksums" : {\n  },\n  "uri" : "http://artifactory.domain.com:8081/artifactory/repo/test.txt"\n}'
    

But if I try to do something like copy or move which uses the `api/` URI then
I get a Tomcat error message:

    
    
    >>response = session.post('http://artifactory.domain.com/api/copy/repo/test.txt?to=/repo/folder/test.txt')
    >>response.status_code
    404
    >>response.text
    u'<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.22 - Error report</title><style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style> </head><body><h1>HTTP Status 404 - /api/copy/repo/test.txt</h1><div class="line"></div><p><b>type</b> Status report</p><p><b>message</b> <u>/api/copy/repo/test.txt</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><hr class="line"><h3>Apache Tomcat/8.0.22</h3></body></html>'
    

I've searched around online and found some people were having `resource not
available` issues when the application's folder had the wrong permissions, but
as far as I can tell from JFrog's website my folder permissions are correct.

I've also checked several log files on the system and they don't even contain
any references to the REST calls I've made which ended up in a Tomcat error:

Catalina log:

    
    
    /var/opt/jfrog/artifactory/logs/catalina/catalina.out
    
    2015-11-17 12:16:47,434 [http-nio-8081-exec-5] [INFO ] (o.a.e.UploadServiceImpl:453) - Deploy to 'repo:test.txt' Content-Length: 6
    

Main Artifactory log:

    
    
    /var/opt/jfrog/artifactory/logs/artifactory.log
    
    2015-11-17 12:16:47,434 [http-nio-8081-exec-5] [INFO ] (o.a.e.UploadServiceImpl:453) - Deploy to 'repo:test.txt' Content-Length: 6
    

Here are the contents of the `/var/opt/jfrog/artifactory` directory:

    
    
    drwxrwxr-x 3 artifactory artifactory 4096 Sep 22 02:00 backup
    drwxrwxr-x 5 artifactory artifactory 4096 Nov  6 08:06 data
    lrwxrwxrwx 1 artifactory artifactory   26 Nov  6 08:06 etc -> /etc/opt/jfrog/artifactory
    drwxrwxr-x 3 artifactory artifactory 4096 Sep 21 13:24 logs
    lrwxrwxrwx 1 artifactory artifactory   27 Nov  6 08:06 misc -> /opt/jfrog/artifactory/misc
    drwxrwxr-x 2 artifactory artifactory 4096 Nov  6 09:23 temp
    lrwxrwxrwx 1 artifactory artifactory   29 Nov  6 08:06 tomcat -> /opt/jfrog/artifactory/tomcat
    lrwxrwxrwx 1 artifactory artifactory   30 Nov  6 08:06 webapps -> /opt/jfrog/artifactory/webapps
    drwxrwxr-x 3 artifactory artifactory 4096 Sep 21 13:24 work
    

Any ideas as to why certain REST calls are successful and others are not?


Answer: Ok so apparently the reason my API calls for copy and move, etc aren't working
is because I need to include `artifactory/` before the `api/` prefix in the
URI string, like this:

    
    
    >>response = session.post('http://artifactory.domain.com/artifactory/api/copy/repo/test.txt?to=/repo/folder/test.txt')
    >>response.status_code
    200
    >>response.text
    u'{\n  "messages" : [ {\n    "level" : "INFO",\n    "message" : "copying repo:test.txt to repo:folder/test.txt completed successfully, 1 artifacts and 0 folders were copied"\n  } ]\n}'
    

