API parameter question in python

  • 1
  • Question
  • Updated 1 week ago
I am creating a python program that will send emails using Sharefile to encrypt them and their attachments. I have a method to create the encrypted email complete, but when I go to upload the encrypted email (), I'm sure where to get the id in https://account.sf-api.com/sf/v3/EncryptedEmails(id)/Upload2 from or what exactly it is. I looked at the results from the create encrypted email submission and the closes items I can find with id in the description are X-SFAPI-RequestID and SFAPI_AuthID). Would someone happen to know the answer?
Photo of Andy Osland

Andy Osland

  • 4 Posts
  • 1 Reply Like
  • annoyed

Posted 2 weeks ago

  • 1
Photo of Pratik Somanagoudar

Pratik Somanagoudar, Employee

  • 14 Posts
  • 1 Reply Like
Hi Andy,

I can help you with this.
POST endpoint used to create encrypted Email in https://api.sharefile.com/rest/docs/resource.aspx?name=EncryptedEmails
does return https://api.sharefile.com/rest/docs/resource.aspx?name=ShareFile.Api.Models.EncryptedEmail  as part of the JSON response. This would have the `Id` field set that can be used to call the /Upload2 endpoint.

Let me know if that works. 
ThanksPratik S
Photo of Andy Osland

Andy Osland

  • 4 Posts
  • 1 Reply Like
Pratik,
   Thank you for you response.  I looked at the properties of ShareFile.Api.Models.EncryptedEmail and don't see a field named 'id' in it per the screenshot below:


Thank you,
    Andy
Photo of Andy Osland

Andy Osland

  • 4 Posts
  • 1 Reply Like
So apparently I had other issues that I had to work through that was causing malformed JSON. I'm afraid that my ignorance has been a kicking my tail? I finally figured out that I needed to do a HTTPSConnection.read() on the response from the HTTPSConnection.request() and then decode it decode('utf-8'). Then I had to use json.loads to see everything. print(json.loads(response.read().decode('utf-8'))), where response is of type 'http.client.HTTPResponse.

Time to go home... :-)
Thank you!
Photo of Pratik Somanagoudar

Pratik Somanagoudar, Employee

  • 14 Posts
  • 1 Reply Like
Yes, sorry if that confused you ShareFile.Api.Models.EncryptedEmail does inherit ShareFile.Api.Models.BaseModel that has the Id property.

Good to know you were able to solve the issue. Kindly let us know if you face any other issues.

ThanksPratikS