Response 500

It returns <response 500>, it was working perfectly fine, before the new update.

What is the mistake? Can someone correct it?

import requests

API_KEY = “myapikey”

with open(“foobar.txt”, ‘r’, encoding=“utf8”, errors=‘ignore’) as f:
words =

with open(“foobar.mp3”, ‘rb’) as f:
mp3data =

filename = “test”
mp3file = {“audio”: (f"{filename}.mp3", mp3data)}

data = {“title”: f"{filename}“,
“text”: f”{words}",
“tags”: [“saveddoc”, “mp3”],
“collection”: “collection_number”}

resp =‘’,
data=data, headers={‘Authorization’: 'Token ’ + API_KEY})
#data=data, files=mp3file, headers={‘Authorization’: 'Token ’ + API_KEY})


I’ve also been encountering 500 errors while following along with examples from here: Python - uploading audio via API - #5 by mescyn and the API documentation here: Contents: — LingQ 1.0 documentation

I understand that there is now a v3 API, but it doesn’t appear to be documented. Has the v2 API been disabled already? Could we document how to use v3?

While it doesn’t appear the v2 api is disabled it does appear that multipart posts to the lessons endpoint no longer function (although to be fair, they were never documented), unfortunately. You can use the external_audio and duration properties, but that doesn’t work the same at all (duration is time in seconds of audio clip, fwiw – the property is documented, but not what its valid values are and it is required for the use of external_audio).

edit: Looking at rooster’s code, it looks like it’s just an blob now, and you might have to create the lesson first, then upload the audio after.