Unable send email in cURL

  • 1
  • Question
  • Updated 23 hours ago
  • (Edited)
I am getting an error  {"code":"BadRequest","message":{"lang":"en-US","value":"Invalid Argument Shares.Items"},"reason":"BadRequest"}
curl -k -H "Content-Type: application/json" -X POST -d "{'Items':'fxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx','Emails':'test@gmail.com','Subject':'Test','Body':'Email Message','CcSender':false,'NotifyOnDownload':true,'RequireLogin':true,'MaxDownloads':30,'ExpirationDays':-1}" "https://company.sf-api.com/sf/v3/Shares/Send" -H "Authorization: Bearer mytoken"
How to pass parameters? So that everything is right
Photo of makhav

makhav

  • 9 Posts
  • 0 Reply Likes

Posted 3 weeks ago

  • 1
Photo of Luke Skrzypek

Luke Skrzypek, Employee

  • 63 Posts
  • 7 Reply Likes
Please see the documentation for the call here https://api.sharefile.com/rest/docs/resource.aspx?name=Shares

Both "Items" and "Emails" are expected to be arrays of strings, whereas you appear to be sending them as strings instead.
Photo of makhav

makhav

  • 9 Posts
  • 0 Reply Likes
Everything worked out! Thank you. Does it send a letter in encrypted form or not?
Photo of Luke Skrzypek

Luke Skrzypek, Employee

  • 63 Posts
  • 7 Reply Likes
The recipient will get a standard share email notification with a link to the file(s). You can decide when creating the share whether the recipient is required to login to access the files.
If you want to send encrypted emails with attached items, then take a look at the EncryptedEmails endpoint
https://api.sharefile.com/rest/docs/resource.aspx?name=EncryptedEmails
(Edited)
Photo of makhav

makhav

  • 9 Posts
  • 0 Reply Likes
Where is this file FileName located, how can I write an e-mail into it?
After Create EncryptedEmail I'm get EncryptedEmail id, but not messageFileId.

Photo of Luke Skrzypek

Luke Skrzypek, Employee

  • 63 Posts
  • 7 Reply Likes
You create a file (or stream) on your machine with the desired message string content. You then post that file data to the encrypted email message using the Upload2 call. FileName is just whatever you want to call that message file you created.

I mispoke about the messageFileId. You set that to the id of the message file you uploaded with the Upload2 step. (Upon success you'll get back an Item object that contains an Id field. That value can be used as messageFileId)
Photo of makhav

makhav

  • 9 Posts
  • 0 Reply Likes
If I do this on my computer, how can I specify the path to this file?
When doing step 2. Based UploadSpecification, I will only get these parameters, no messageFileId among them.
Photo of Luke Skrzypek

Luke Skrzypek, Employee

  • 63 Posts
  • 7 Reply Likes
The UploadSpecification contains information about where to post the file data to (the same way you would upload a regular file). See the three Uri fields listed in the UploadSpecification documentation. 
Photo of makhav

makhav

  • 9 Posts
  • 0 Reply Likes
I upload Encrypted Email Message like this
curl -k -H "Content-Type: application/json" -X POST -d "{'Method':'Standard','Raw':true,'FileName':'message.txt','FileSize':1}" "https://company.sf-api.com/sf/v3/EncryptedEmails(myEncryptedEmail id)/Upload2 -H "Authorization: Bearer mytoken"
I get ChunkUri and upload file 
curl -k -F FileName=@"M:\message.txt" "myChunkUri"
I get only message "Ok"
How can I get messageFileId? Or am I doing something wrong?

(Edited)
Photo of makhav

makhav

  • 9 Posts
  • 0 Reply Likes
Thank you so much.