2

I'm trying to replicate this cURL onliner:

curl -i -XPOST 'http://httpbin.org/post?db=data' --data-binary 'files,host=server10,folder=max value=0.64 1434055562121200000'

to python with the help of python-requests.

I've tried:

import requests
payload = {'files,host=server10,folder=max value=0.64 1434055562121200000':'\n'}
or payload = {'files,host':'server10,folder=max value=0.64 1434055562121200000'}
or {'files,host=server10,folder=max value=0.64 1434055562121200000':''}
or {'files,host=server10,folder=max value=0.64 1434055562121200000'}

r = requests.post('http://httpbin.org/post?db=data', data=payload)

I need some pointers or help to get past this snag, because it's possible right?

1

1 Answer 1

1

Answering my self.

import requests
url = 'http://10.10.10.10:8086/write?db=data'
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
payload = "cpu,host=server01,region=us-west value=0.64 1434055562000000000\n"
r = requests.post(url, data=payload, headers=headers)

With this, posting to influxdb via python works the same as the above cURL onliner.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, helped me a lot. Couldn't find the right header to use here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.