Sending file via API connector

Hi there,
my name is Julien, new to Bubble but not so new to No-Code (experienced MIT App inventor).
I am also struggling with sending a file to an API in Bubble.
The mentionned API is :

import requests

API_URL = “https://api-inference.huggingface.co/models/speechbrain/asr-wav2vec2-commonvoice-fr
headers = {“Authorization”: “Bearer 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”}

def query(filename):
with open(filename, “rb”) as f:
data = f.read()
response = requests.request(“POST”, API_URL, headers=headers, data=data)
return json.loads(response.content.decode(“utf-8”))

output = query(“sample1.flac”)

: I guess I have to convert my file to UTF8 using @aaronsheldon plugin.

Let’s try, even if not so much coding experience…

I had to tell you, I was working on this study project of mine, and I had hacked my way out of this problem so bad, I was feeling embarassed… That is, until I tried your plugin. That action “Write from Base 64” made my code clean again. Just came her to say thank you very much. :pray: :pray:

Thank you, easy fix! I wasn’t using form-data to send the file, I was using raw data with the file’s link.