0

This is the curl command: echo Hello world. | curl -F 'f:1=<-' ix.io

I tried this, but it didn't work as the server threw a 400 instead of a 200 status code.

import requests
requests.post("http://ix.io", files={"file": ("", "Hello world.")}, data={"f":"1=<-"})

How would I replicate that command?

Asylum
  • 77
  • 1
  • 7
  • 1
    What specifically are you trying to accomplish? Upload "Hello world." to the server? Or upload the contents of stdin or some file to the server? The answer to the former is very simply: `requests.post("http://ix.io", data={"f": "Hello world."})`. The answer to the later to to replace the string with however you want to get your data. – Dunes Nov 15 '21 at 14:16
  • Well, that's the thing, you're wrong, the person who made the site, made the documentation really bad, I figured it out with a guy from a coding server. The data should actually be `data={"f:": "Hello world."}` because the guy has `f:N` in the docs and I, and you also, thought that it's just like `key:value` but it's `key::value`, I really don't know why. – Asylum Nov 15 '21 at 15:24

1 Answers1

0

This way you can get POST accepted by ix.io server:

requests.post("http://ix.io", files={ 'f:1': ("Hello World") })

Take a look at How to send a "multipart/form-data" with requests in python? for detailed explanation on what can be put as files parameter.

arekm
  • 56
  • 5
  • Hey, I know Python a good bit, I already got it solved and your answer isn't correct, look at my responses :D The only reason I asked this is because the docs were really confusing... – Asylum Nov 22 '21 at 19:38
  • Ok. What do you mean by not correct? It works and is accepted by ix.io server. – arekm Nov 23 '21 at 09:00