cancel
Showing results for 
Search instead for 
Did you mean: 

401 unauthorized when uploading document

achraf13
Champ in-the-making
Champ in-the-making

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 ACCEPTED ANSWER

achraf13
Champ in-the-making
Champ in-the-making

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

View answer in original post

3 REPLIES 3

narkuss
Star Contributor
Star Contributor

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
Champ in-the-making
Champ in-the-making

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

EddieMay
World-Class Innovator
World-Class Innovator

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!