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})


1 Like

i’m also unable to post mp3s now. i just about went crazy trying to do it.

Sorry to hear that, we will investigate the issue. Do you get that error for any mp3 file you try to import?

it is still the same, with and without mp3s.

Can you please send one of the audio files you are unable to import to support(at) I’d like to try importing it on my end, since I am unable to reproduce the issue with various audio files I tried to import. Thanks a lot!

I’m also hitting 500 errors when attempting any upload through the v2 lessons API. Here is an example without any mp3 that ends up in a 500 error on my side:

import requests
h= "{'Authorization': 'Token xxx', 'Content-Type': 'multipart/form-data; boundary=c38aa374c1994deca3bfd429d97e948c'}"
m= "<MultipartEncoder: [('title', 'test test test'), ('status', 'private'), ('collection', '1418933'), ('text', 'foo bar buzz bazz')]>"
r ='', data=m, headers=h)
print (r.text)


Has this code worked in the past and recently not working? Or are you looking for guidance on how to upload to LingQ via API?

I am trying to write an uploading script for a set of podcast mp3s that I would like to upload to lingq. While I have not personally had this working before, I’ve been following along examples such as Python - uploading audio via API - #5 by mescyn that have worked for folks before.

I did eventually get text-only uploading to work with an explicit ‘Content-Type’ of ‘application/json’. I’ve had no luck getting mp3 uploads going.

I would very much appreciate guidance on how to upload mp3s via the lingq API. I want to avoid RSI from manually uploading the 100 or so MP3s I have. I’ll open a separate thread for that.

1 Like

@Chipmaster sent you some code that that should help. I probably wouldn’t send 100 mp3s to be transcribed at once. If you’re uploading with a transcript should be fine to do 100 in a row. Server seems to struggle with 3-4 concurrent transcribes. You can also download my Course Upload Extension Source Code to find the solution I wrote for audio uploading in Javascript.


Thank you for your github link. with a few adjustment(copy-paste his code into mine), it is running now.

you need to put the text file in “textfiles” folder and mp3 files in “mp3files”.
Based on their names it will zip them and upload them to lingq.
List will look like this [(1.txt, 1.mp3])

Also you should install requests_toolbelt

#!/usr/bin/env python
import requests, os
from requests_toolbelt.multipart.encoder import MultipartEncoder
from glob import glob

postAddress = ""
collection = "YOURCOURSE"

listoftxts = glob("textfiles/*.txt")
listofmp3s = glob("mp3files/*.mp3")

for textfile, audiofile in list(zip(listoftxts, listofmp3s)):
    title = audiofile.replace('.mp3', '').replace("mp3files/","")
    with open(textfile, 'r', errors='ignore') as f:
        text =
    with open(audiofile, 'rb') as f:
        audio =
    m = MultipartEncoder([
            ('title', title),
            ('text', text),
            ('collection', collection),
            ('audio', (audiofile, audio, 'audio/mpeg')),
            ('save', "true")
    h = {'Authorization': 'Token ' + API_KEY,
         'Content-Type': m.content_type}
    r =, data=m, headers=h)
    print("Status Code: ", r.status_code)