Error 403 with PUT or DELETE http calls

cancel
Showing results for 
Search instead for 
Did you mean: 
FabioVaprio
Member II

Error 403 with PUT or DELETE http calls

I've installed Alfresco Community 7.3 with docker, and I'm developing a frontend application with Angular.

It use a Tomcat webserver. When I try to execute a PUT or DELETE http call, server send back the following error: "status: 403, statusText: 'Forbidden".

The routine is the following (eg. for delete a document):

sAlfEliminaFile(ticket: string, idFile: string){
    const headers = new HttpHeaders({
      'Authorization': 'Basic ' + btoa(ticket),
    });

    return this.http.delete('/alfrescoapi/-default-/public/alfresco/versions/1/nodes/22f98143-eb5e-48f0-8c40-4534c1fe73d1', {headers : headers })
  }

I'm using a proxy to avoid CORS problem, with following parameters:

{
    "/alfrescoapi": {
      "target": "http://localhost/alfresco",
      "secure": false,
      "pathRewrite": {
        "^/alfrescoapi": "/api"
      },
      "changeOrigin": true
    }
} 

I've already tried to change the param "changeOrigin" to false but it does not work. Credentials are corrects, I've also tried with admin credentials, with the same result.

What I can do to solve? Thanks.

5 Replies
angelborroy
Alfresco Employee

Re: Error 403 with PUT or DELETE http calls

I guess the problem is that service doesn't exist.

I created a workaround in this project:

https://github.com/keensoft/alfresco-remove-version

It's required to create a new Web Script (legacy REST API) in Repository to handle this DELETE invocations:

https://github.com/keensoft/alfresco-remove-version/blob/master/remove-version-repo/src/main/resourc...

 

Hyland Developer Evangelist
angelborroy
Alfresco Employee

Re: Error 403 with PUT or DELETE http calls

I addition... review your URL, since it looks incorrect.

This is the right one:

'/alfresco/api/-default-/public/alfresco/versions/1/nodes/22f98143-eb5e-48f0-8c40-4534c1fe73d1'

With an additional slash between "alfresco" and "api"

Hyland Developer Evangelist
FabioVaprio
Member II

Re: Error 403 with PUT or DELETE http calls

Thanks for your help,

the URL it's right, because I create an alias on proxy conf file

"pathRewrite": {
        "^/alfrescoapi": "/api"
      },

So, "alfrescoapi" is changed in "api". All'other API I developed work well.

 

FabioVaprio
Member II

Re: Error 403 with PUT or DELETE http calls

Sorry, but I didn't understand your answer. May you explain me better?

This API is described in "Alfresco Content Services REST API" and the problem is the same for PUT method.

FabioVaprio
Member II

Re: Error 403 with PUT or DELETE http calls

I solved by installing Alfresco on port 8080 instead of 80.

I don't know if NGIX reverse proxy has a specific rule for port 80.