Help with 'files' API

I am creating an OctoPrint plugin.
Uses Python and Kivy.
I am having trouble with the 'select' function of the 'files' API.

I can list all the files with no problem, and I can choose from the list, but I can not get the API to 'Select' the file so it can be printed.

If I issue the following file segment:

    def select_file (self, onelinelistitem):
        print ('file: ', onelinelistitem.text)
        file_data = {'command':'select', 'print': False}
        print(filesapiurl + '/local/' + onelinelistitem.text + str(file_data))
        r = requests.post(filesapiurl + '/local/' + onelinelistitem.text, headers=headers, json=file_data, timeout=httptimeout)
        print('STATUS CODE: ' + str(r.status_code))

I get the following output on the console:

file:  Seifenhalter.gcode
http://127.0.0.1:5000/api/files/local/Seifenhalter.gcode{'command': 'select', 'print': False}
STATUS CODE: 409

So it seems that the request is not malformed, but can not be processed.

Any suggestions?

409 means conflict, which means something else is blocking this operation that would conflict. Is the printer connected? Is there another file already printing?

To select a file, there must be a connected printer and no ongoing print.

Now I feel stooopid...
"The car won't go anywhere!"
"Did you try turning it on?"

Connecting did the trick. I think the fact that I could list files and pick them meant that I could load them too.

Thanks for the quick answer!

BTW if you are dong this as a plugin you don't need to use the API at all...see this answer I posted not too long ago.