Skip to main content

How to UploadMediaFile in Python

nschainblatt-1755
Original Poster

Hello, I am trying to upload an image via the UploadMediaFile method, I can successfully create a MediaFile object and call it in a get request. I am unsure how to actually upload the binary image data along with the MediaFile in python. The error I am getting is:

 

default() missing 1 required positional argument: 'o'

or

invalid json data

mediaFile = { 'name': original_file_name + extension, 'fromDate': today, 'solutionId': fuel_transaction_id, 'device': {'id': device_id}, 'metaData': {'name': original_file_name, 'size': image.size} }   api.add('MediaFile', entity=mediaFile) media_file = api.get('MediaFile', search={'solutionId': fuel_transaction_id}) # Results in an error api.call('UploadMediaFile', mediaFile=media_file[0], optimizedStream=bytes)

 

Join the conversation

You need to be logged in to reply to this post and participate in the Geotab Community discussions.

Top Answers

Hi @nschainblatt-1755​ -

 

The issue here is likely to be that UploadMediaFile is going to be looking for a multipart form. There's a conversation about it from last week if you look at the last two replies in this question post: https://community.geotab.com/s/question/0D7Ht000009BRsSKAW/detail.

 

It was a different API involved, but the approach for UploadMediaFile would be the same, and it looks like it was solved today (by another person at BlueArrow, which may give you a boost).

2 Replies

EishiFUN
Geotabber

Hello @nschainblatt-1755​ ,

 

Thank you for asking your question in our community. I wanted to let you know I have contacted our SDK experts about this question. I will let you know what I hear as soon as I do.

 

Thank you for your patience while we look into this.

 

Have a good one!

Eishi FUN

Hi @nschainblatt-1755​ -

 

The issue here is likely to be that UploadMediaFile is going to be looking for a multipart form. There's a conversation about it from last week if you look at the last two replies in this question post: https://community.geotab.com/s/question/0D7Ht000009BRsSKAW/detail.

 

It was a different API involved, but the approach for UploadMediaFile would be the same, and it looks like it was solved today (by another person at BlueArrow, which may give you a boost).

Still have questions?