I have to upload a file from a server to docs management, but i have a problem at upload file step. For information, i do my script with Dynamics NAV.
Before doing the upload from Dynamics NAV, i tried with Git Bash and cURL commands : it works.
This is the permissions that i have : see here
This is all steps and what i can do:
When i do the upload step, i have an error 401 : Forbidden but i don't know where i'm suppose to go for set good permissions.
This is the cURL command :
curl -X PUT -H "Authorization: Bearer nq4dc0KRWeaaUnyIJA8aN0MIKi3j"
--data-binary '@\\server\folder\subfolder\file.rvt'
"https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/2448af43-45f3-4b81-a8cf-38c69b03197b.rvt"
So after seeing this, i don't need to set special permissions for upload a file.
This this my Dynamics Nav code :
HttpWebRequestMgt.Initialize(STRSUBSTNO('https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/%1',Filename));
HttpWebRequestMgt.DisableUI;
HttpWebRequestMgt.SetMethod('PUT');
HttpWebRequestMgt.SetContentType('application/octet-stream');
HttpWebRequestMgt.AddHeader('Authorization','Bearer ' + Token);
FileManagement.BLOBImportFromServerFile(TempBlob,ServerFolder+'\'+Filename);
HttpWebRequestMgt.AddBodyBlob(TempBlob);
CLEAR(TempBlob);
TempBlob.Blob.CREATEINSTREAM(ResponseInStream);
HttpWebRequestMgt.GetResponse(ResponseInStream,HttpStatusCode,ResponseHeaders);
ResponseInStream.READTEXT(ResponseText);
CLEAR(HttpWebRequestMgt);
CLEAR(TempBlob);
With this i need a specific permissions ...
Some suggestions ?
I found the solution.
BIM360Setup.GET;
SalespersonPurchaser.GET(BIM360Setup."Default Job Admin");
IF Token = '' THEN
Token := Get3LeggedToken;
StorageID := COPYSTR(FileURNID,STRPOS(FileURNID,'/') + 1);//***
HttpWebRequestMgt.Initialize(STRSUBSTNO('https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/%1',StorageID));
HttpWebRequestMgt.DisableUI;
HttpWebRequestMgt.SetMethod('PUT');
HttpWebRequestMgt.SetContentType('application/x-www-form-urlencoded');
HttpWebRequestMgt.AddHeader('Authorization','Bearer ' + Token);
HttpWebRequestMgt.SetReturnType('*/*');
FileManagement.BLOBImportFromServerFile(TempBlob,ServerFolder+'\'+Filename);
HttpWebRequestMgt.AddBodyBlob(TempBlob);
CLEAR(TempBlob);
TempBlob.Blob.CREATEINSTREAM(ResponseInStream);
HttpWebRequestMgt.GetResponse(ResponseInStream,HttpStatusCode,ResponseHeaders);
ResponseText := TempBlob.ReadAsText('',TEXTENCODING::UTF8);
CLEAR(HttpWebRequestMgt);
CLEAR(TempBlob);