POST both image and text

I’m trying to send a small image and some sensor values from a remote raspberry pi using POST. I can send the sensor values just fine, and I can send the image no problem, but I can’t seem to get it to work when I try to do them both in one POST.

url = { 

files = {
    'file': open('test.jpg','rb')

values = {
    'datetime': dateTime,
    'airqual': airqual,
    'temperature': temperature,
    'pressure': pressure, 
    'humidity': humidity

r =, files=files, data=values)

hey tigerweet,

could you send us a link to the raspberry pi API documentation that you use? Please include also log messages that you see on the console when you execute your code.

It is difficult to spot the issue without more information.


Hi Dennis! Thank you for replying,

I’m just running it on python3 and POSTing the data to It posts the data or the file seperately just fine, but only the file when I post both of them. I have the same problem when I run the script from my desktop PC.

#!/usr/bin/env python
import requests
url = 'https://url'

files = {'file': open('test.txt','rb')}

values = {'text':'foo', 'text2':'bar'}

r =, files=files, data=values)

Do you have the source code of the server by chance? Perhaps the Github repository?

Also, I guess “https://url” is not really the URL to the server. Where does this server run? on your computer?

Please include the error message that you receive when you run your code.


ha, no, the server is one of the “toilets” at a Post Test Server You can see the dump at PTS - V2 . I don’t see an error message, but the server reports only a file is sent, nothing else.

Maybe the backend has a bug. But it is difficult to find out more if we don’t have access to the source code.

Hi Dennis,

It looks like it was the backend? I tried it on a different test server ( and it worked like a charm!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.