401 unauthorized when uploading document

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

401 unauthorized when uploading document

Jump to solution

I want to upload file using aflresco restApi
this is my function 

 
const formData = new FormData();
  formData.append('filedata',file);
  const newheaders = new HttpHeaders().set('Authorization''Basic '+token);
  const uri = `http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children`;
  console.log("this is token before Uploading"+token);
  const req = new HttpRequest('POST'uriformData, {
    headers: newheaders,
    reportProgress: true,
    responseType: 'json'
  });
 
  return this.http.request(req); 
 

the token before uploading is valid ; it's tested with postman

 

 

1 Solution

Accepted Solutions
achraf13
Member II

Re: 401 unauthorized when uploading document

Jump to solution

i used a different identity provider , excluding the alfresco url  solved  the problem!

View solution in original post

3 Replies
narkuss
Established Member II

Re: 401 unauthorized when uploading document

Jump to solution

Hi, 

If you are using a JWT token, you should change "Basic " to "Bearer ". If you can execute this same call through Postman, then I think you should check your HttpRequest and formData objects.

Hope this helps

achraf13
Member II

Re: 401 unauthorized when uploading document

Jump to solution

i used a different identity provider , excluding the alfresco url  solved  the problem!

View solution in original post

EddieMay
Community Manager
Community Manager

Re: 401 unauthorized when uploading document

Jump to solution

Hi @achraf13 

Glad you got it resolved and thanks for updating your thread.

Cheers,

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!