How to add the attachment as column data in smartsheet for the media file?

What I’m trying to do:
I am trying to create a record of caller where I will read an email parse it and add the record on smartsheet(SAAS product). I can easily append the caller details but I also need to add the voice mail(media file). I am trying to attach Anvil Lazy Media(<anvil._server.LazyMedia object at 0x7f292c4b6810>) file to my smartsheet but no luck.
What I’ve tried and what’s not working:

  1. Attaching as URL(url generated by anvil for the media)
  2. Attaching the bytes code → to_bytes of anvil

Code Sample:
`test_attachment_row = app_tables.test_data.get(name=‘voice_mail_test’)
test_attachment_data = test_attachment_row[‘attach’]

configuration = conf['configuration']
smartsheet_client = smartsheet.Smartsheet(configuration['SMARTSHEET_API_KEY'])
sheet = smartsheet_client.Sheets.get_sheet(configuration['SMARTSHEET_SHEET_ID'])
response = smartsheet_client.Sheets.list_sheets(include_all=True)
new_row = smartsheet.models.Row()
new_row.to_top = True
new_row.attachments = [test_attachment_data.get_bytes()]

# This contains the column [] of the columns we want to update
new_row.cells.append({
    'column_id': configuration['SMARTSHEET_COLUMN_ID'].get('notified_number'),
    'value': json_file.get('notified_number')
})

new_row.cells.append({
    'column_id': configuration.get('SMARTSHEET_COLUMN_ID').get('caller_name'),
    'value': json_file.get('caller_name')
})
new_row.cells.append({
    'column_id': configuration.get('SMARTSHEET_COLUMN_ID').get('date_time'),
    'value': json_file.get('date_time')
})
try:
  new_row.cells.append({
    'column_id':configuration.get('SMARTSHEET_COLUMN_ID').get('voice_mail'),
    'value': json_file.get('voice_mail','12')
  })
except Exception as e:
  print("Errro", e)
  new_row.cells.append({
    'column_id':configuration.get('SMARTSHEET_COLUMN_ID').get('voice_mail'),
    'value':'NA'
  })

Clone link:
share a copy of your app

Hi @surendra.nepal2020,

I’ve not used the Smartsheet API before but according to their API documentation on attachments you can use a multipart upload request for attachments. I’ve written about doing that with the Trello API in Chapter 3 - Step 3 of our Trello API tutorial. Hopefully, that should get you going in the right direction.

Thanks @ryan I will go through it.