I am trying to replicate shell command:
curl -X POST -u 'user:pass' https://databricksda.kdc.capitalone.com/api/1.2/commands/execute -d 'language=scala&clusterId=123&contextId=456&command=sc.parallelize(1 to 5).collect;'
into Python code using Requests library:
import requests
What is a proper syntax for this example (curl -X POST)?
Once you import the requests
, convert the data being passed to an Object/dictionary and make the POST request. Here's the documentation
import requests
data = {
'language': 'scala',
'clusterId': '123',
'contextId': '456',
'command': 'sc.parallelize(1 to 5).collect;'
}
requests.post('https://databricksda.kdc.capitalone.com/api/1.2/commands/execute', data=data, auth=('user', 'pass'))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.