Question

I want to put a request to HDFS REST API.

It works in the RESTClient.

But it failed when i translate it to Python edition( python httplib).

And i can't use this in Curl for some reason.

Anybody know httplib put, can help me translate it to Python edition?

Here is the RESTClient edition:

method: PUT

URL: http://www.somedomain.com:50070/webhdfs/v1/levi/4?op=CREATE

Was it helpful?

Solution

With Requests:

import requests
requests.put('http://www.somedomain.com:50070/webhdfs/v1/levi/4?op=CREATE')

With httplib:

import httplib

connection =  httplib.HTTPConnection('www.somedomain.com:50070')
connection.request('PUT', '/webhdfs/v1/levi/4?op=CREATE')

response = connection.getresponse()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top