Just can't seem to get Shares/Send to SEND (.NET)

  • 1
  • Problem
  • Updated 3 years ago
My goal is simple: I want to upload some files to a folder I create and notify one or more clients that the files are available to them.

I'm using .NET but cannot use the .NET SDK since I'm stuck with Visual Studio 2010 / .NET Framework 4.0 so I'm using the two ShareFile.Api.Client assemblies (version 3.0.0.0) and Newtonsoft.Json (version 8.0.0.0).

Here's my procedure:

1) I authenticate, get my root folder Id
2) I create a new folder in my root, upload a file to it -- that all works perfectly.

============================================================================

3) I then share the files using the below json, URL, details.

f####-####-###-#####-#### is the Id of the file I uploaded, not the folder I created

json:

{
  "Type": "Send",
  "Title": "My test!",
  "Items": [
    {
      "Id": "f####-####-###-#####-####"
    }
  ],
  "Recipients": [
    {
      "User": {
        "Email": "someone@somewhere.com"
      }
    }
  ],
  "ExpirationDate": "2016-02-25",
  "Subject": "Welcome test",
  "Body": "My test!",
  "RequireLogin": true,
  "RequireUserInfo": false,
  "MaxDownloads": -1
}


NB: Whether notify is true or false the returned share details always shows HasSentMessage as false
and no email is received.
URI: https://mysubdomain.sharefile.com/sf/v3/Shares?notify=true  
Method: POST
<request object>.ContentType = "application/json"
write json to result of <request object>.GetRequestStream()

============================================================================

4) Since creating the share didn't send an email, I try using Shares/Send using the below json, URL, details.

s########### is the Id of the share I created above

json:

{
  "Items": [
    {
      "Id": "s#############"
    }
  ],
  "Emails": [
    {
      "User": {
          "Email": "someone@somewhere.com"
      }
    }
  ],
  "Subject": "Welcome test",
  "Body": "My test!",
  "RequireLogin": true,
  "SendAnon": false,
  "RequireUserInfo": false,
  "ExpirationDays": 7,
  "NotifyOnDownload": true,
  "IsViewOnly": false,
  "MaxDownloads": -1,
  "UsesStreamIDs": false
}

URI: https://mysubdomain.sharefile.com/sf/v3/Shares/Send?notify=true
Method: POST
<request object>.ContentType = "application/json"
write json to result of <request object>.GetRequestStream()


I always get an error that reads: 
{"code":"BadRequest","message":{"lang":"en-US",
"value":"Invalid Argument Share.Items"},"reason":"BadRequest"}

I've tried substituting the created folder Id, the root Id, my dog's Id and I always get the same error.

============================================================================

5) As a temporary workaround I'm using Shares/Alias which DOES send an email notification but I can't customize it with my own subject or body.

URI: https://mysubdomain.sharefile.com/sf/v3/Shares(<the Id of the share>)/Alias?email=someone@somewhere.com&notify=true


Can someone show me the error in my efforts, please?
Photo of Joe Magura

Joe Magura

  • 6 Posts
  • 0 Reply Likes

Posted 3 years ago

  • 1
Photo of Eliezer Encarnacion

Eliezer Encarnacion, Software Engineer

  • 732 Posts
  • 102 Reply Likes
Hey Joe,

Thanks for the all the info you provided. You were very close to getting the correct format! The problem is that the JSON params for the Shares/Send request is slightly different than the one for the plain Create Share. 

Try Shares/Send again, but instead of passing the Users and Items parameters as nested objects, simply pass a list of strings, like this:

{
"Items":["fileid", "fileid2"],
"Emails": ["email1","email2"]
}

We'll make sure this is documented correctly, as it can be confusing.

Thanks!
Eli
Photo of Joe Magura

Joe Magura

  • 6 Posts
  • 0 Reply Likes
Eli,

  Much of what I know about the API comes from reading your excellent replies!  I really appreciate having someone with your expertise help me.

  You were exactly right--once I built my items list (of FileIds, not the single ShareId) the way you laid out, it worked perfectly.  The funny thing is I had learned that I have to pass the emails in that format (likely from one of your posts), but I'd only ever seen items passed the way I was initially.

Once again, Thanks very much for this help and all your past, indirect, help,

Joe
Photo of Eliezer Encarnacion

Eliezer Encarnacion, Software Engineer

  • 732 Posts
  • 102 Reply Likes
Thanks Joe, I'm happy to know that I have been able to help somehow. 

And you're not wrong, passing the emails in that format is the correct way to do it if you are calling POST /sf/v3/Shares. It changes only if you are using POST /sf/v3/Shares/Send or /sf/v3/Shares/Resend. It can be rather confusing and this is part of our list of things to "fix" in a future api update. 

Let us know if you run into any other issues.

Thanks!
Eli