jhoerr / box-csharp-sdk-v2

A C# client for the Box API (v2).
http://developers.box.com/docs/
11 stars 15 forks source link

Creating a shared link #35

Closed everettevola closed 11 years ago

everettevola commented 11 years ago

I am having trouble creating a shared link on a file. From what I can tell on the box developer documentation, only the "Access" property must be set on the SharedLink object prior applying it to a file. The following code is failing with a BoxException.

SharedLink sharedLink = new SharedLink() { Access = BoxApi.V2.Model.Enum.Access.Collaborators }; file = _manager.ShareFileLink(file, sharedLink);

Can you point me in the right direction?

everettevola commented 11 years ago

I have been looking through your source code and something struck me as odd. In Permissions.cs, BoxApi.V2.Model, the CanDownload property has JsonProperty attribution for "item_collection". Shouldn't this attribution point to "can_download"?

I am not sure if this is related to the issue I am having in my initial comment above, but it does look suspicious.

jhoerr commented 11 years ago

Both things are bugs. I've added tests and fixed the issues. Will commit them shortly!

jhoerr commented 11 years ago

Fixed in 35d85fefc2dcd5ac905b74d5fc739075f9bb1e39. Let me know if you still have any problems.

ibelong2sathish commented 11 years ago

There is an issue with shareLink, it is throwing the error as "Bad Request".

The code that I had used to generate the shared link as follows:

Dim expectedLink As SharedLink = New SharedLink(BoxApi.V2.Model.Enum.Access.Open, Permissions:=New Permissions() With {.CanDownload = True, .CanPreview = True}) Dim linkedFile As File = objBox.ShareLink(objFile, expectedLink)

Kindly point me with the right direction..

elattoo commented 10 years ago

Hello. I'm having the "Bad Request" issue as well. Anybody still monitoring this? I'm using v2 c# api.

BoxFile file = boxManager.CreateFile(folder, fileName, fileStream);
file.Description = descriptiveTags;
boxManager.Update(file);
SharedLink sharedLink = new SharedLink(BoxApi.V2.Model.Enum.Access.Open);
BoxFile linkedFile = boxManager.ShareLink(file, sharedLink);
boxManager.Delete(linkedFile);

It barfs on the "ShareLink" attempt. Everything prior is working fine. BoxFile is an alias for BoxApi.V2.Model.File, and BoxFolder = BoxApi.V2.Model.Folder.

Thanks! Kevin