Create Shared Links API Forbidden Error - .NET SDK
Hi Everyone,
I am facing an issue while I am trying call Create Shared Links API via .NET SDK. The error thrown to me says: Box.V2.Exceptions.BoxAPIException: The API returned an error [Forbidden | skq87mh3ik4c7p75.1ca06a744043a75b4d195c44fed77a467] forbidden - Forbidden
The code I have been using for the same is as follows and the error happens in the last line of the code:
'Initialize Variables
Dim config As Box.V2.Config.IBoxConfig
Dim json,JSON_FilePath As String
Dim sdk As Box.V2.JWTAuth.BoxJWTAuth
Dim token As Threading.Tasks.Task(Of String)
Dim client As Box.V2.BoxClient
Dim folderInfo As Threading.Tasks.Task(Of Box.V2.Models.BoxCollection(Of Box.V2.Models.BoxItem))
Dim fileInfo As Threading.Tasks.Task(Of Box.V2.Models.BoxFile)
Dim sharedLinkRequest As Box.V2.Models.BoxSharedLinkRequest
Dim boxFile As Threading.Tasks.Task(Of Box.V2.Models.BoxFile)
'Read JSON Configuration File
JSON_FilePath = "<JWT_CONFIG_PATH>"
Using reader As StreamReader = New StreamReader(JSON_FilePath)
json = reader.ReadToEnd
End Using
'Create BOX Configuration Object
config = Box.V2.Config.BoxConfig.CreateFromJsonString(json)
'Initialize SDK Client
sdk = New Box.V2.JWTAuth.BoxJWTAuth(config)
token = sdk.AdminTokenAsync()
client = sdk.AdminClient(token.Result.ToString)
folderInfo = client.FoldersManager.GetFolderItemsAsync("<FOLDER_ID>",10)
For Each item As Box.V2.Models.BoxItem In folderInfo.Result.Entries
fileInfo = client.FilesManager.GetInformationAsync(item.Id)
Console.WriteLine("Process for the file ID: "+fileInfo.Result.Id)
sharedLinkRequest = New Box.V2.Models.BoxSharedLinkRequest()
sharedLinkRequest.Access = Box.V2.Models.BoxSharedLinkAccessType.open
sharedLinkRequest.Permissions = New Box.V2.Models.BoxPermissionsRequest()
sharedLinkRequest.Permissions.Download = True
sharedLinkRequest.Permissions.Edit = True
boxFile = client.FilesManager.CreateSharedLinkAsync(fileInfo.Result.Id,sharedLinkRequest)
Console.WriteLine(boxFile.Result.Name.ToString + " ----> " + boxFile.Result.SharedLink.Url.ToString)
Next
投稿コメントは受け付けていません。
コメント
2件のコメント