curl

Connecting to remote Elasticsearch server with python's Elasticsearch package

Connecting to remote Elasticsearch server with python's Elasticsearch package Question: I want to use a remote Elasticsearch server for my website. I have used elastic.co/ cloud service to create a remote Elasticsearch server. I can connect/ping remote Elasticsearch server using the following command (it is scrubbed of sensitive info): curl -u username:password https://55555555555bb0c30d1cba4e9e6.us-central1.gcp.cloud.es.io:9243 After tying …

Total answers: 2

Downloading a large file in parts using multiple parallel threads

Downloading a large file in parts using multiple parallel threads Question: I have a use case, where a large remote file needs to be downloaded in parts, by using multiple threads. Each thread must run simultaneously (in parallel), grabbing a specific part of the file. The expectation is to combine the parts into a single …

Total answers: 4

Protocol "https" not supported or disabled in libcurl ubuntu python

Protocol "https" not supported or disabled in libcurl ubuntu python Question: I am trying to run a repository from github in ubuntu18. after running python3 setup.py develop –user I got the error CMake Error at libmypaint-stamp/download-libmypaint.cmake:159 (message): Each download failed! error: downloading ‘https://github.com/mypaint/libmypaint/releases/download/v1.3.0/libmypaint-1.3.0.tar.xz’ failed status_code: 1 status_string: “Unsupported protocol” log: — LOG BEGIN — Protocol …

Total answers: 3

Convert from curl python Request Error error 401

Convert from curl python Request Error error 401 Question: Im having trouble converting the curl request into a python code request. Working Curl request curl -X POST “http://xxxxxx” -H “accept: application/json” -H “Content-Type: application/x-www-form-urlencoded” -H “Authorization: Token 882a6ec053ff6dbac623eff400f67c0bb6ade399” -d “name=namename” Not working python request headers = { ‘Authorization ‘: ‘Token ‘ + “token”, ‘Content-Type’: ‘application/json’, …

Total answers: 2

Send JSON-Request to Flask via Curl

Send JSON-Request to Flask via Curl Question: I setup a very simple post route in flask like this: from flask import Flask, request app = Flask(__name__) @app.route(‘/post’, methods=[‘POST’]) def post_route(): if request.method == ‘POST’: data = request.get_json() print(‘Data Received: “{data}”‘.format(data=data)) return “Request Processed.n” app.run() This is the curl request I am trying to send from …

Total answers: 1

convert curl to python requests

convert curl to python requests Question: I’m trying to convert the following curl request to a python requests (using the Requests) curl -X POST -H “Authorization: Bearer <TOKEN>” -H “Cache-Control: no-cache” -H “Content-Type: multipart/form-data” -F “modelId=CommunitySentiment” -F “document=the presentation was great and I learned a lot” https://api.einstein.ai/v2/language/sentiment the response would be a json {“probabilities”: [{ …

Total answers: 3

GET curl call not returning JSON object

GET curl call not returning JSON object Question: curl -D- -X GET -H "Authorization: Basic ——————–=" -H "Content-Type: application/json" https://jira.———–.net/rest/api/latest/search?jql=assignee=wwilson This returns actual correct output, but when I try to pipe a command to format it it tells me that no JSON object could be decoded. {"expand":"names,schema","startAt":0,"maxResults":50,"total":1,"issues": [{"expand":"editmeta,renderedFields,transitions,changelog,operations","id":"11497" ,"self":"https://jira.some-company.net/rest/api/latest/issue/11497","key":"QA- 121","fields":{"summary":"Test_Run","progress": …. Not going to give …

Total answers: 1

Upload Image using POST form data in Python-requests

Upload Image using POST form data in Python-requests Question: I’m working with wechat APIs … here I’ve to upload an image to wechat’s server using this API http://admin.wechat.com/wiki/index.php?title=Transferring_Multimedia_Files url = ‘http://file.api.wechat.com/cgi-bin/media/upload?access_token=%s&type=image’%access_token files = { ‘file’: (filename, open(filepath, ‘rb’)), ‘Content-Type’: ‘image/jpeg’, ‘Content-Length’: l } r = requests.post(url, files=files) I’m not able to post data Asked By: …

Total answers: 8

Execute curl command within a Python script

Execute curl command within a Python script Question: I am trying to execute a curl command within a python script. If I do it in the terminal, it looks like this: curl -X POST -d ‘{“nw_src”: “10.0.0.1/32”, “nw_dst”: “10.0.0.2/32”, “nw_proto”: “ICMP”, “actions”: “ALLOW”, “priority”: “10”}’ http://localhost:8080/firewall/rules/0000000000000001 I’ve seen recommendations to use pycurl, but I couldn’t …

Total answers: 9

Curl works but not Python requests

Curl works but not Python requests Question: I am trying to fetch a JSON response from http://erdos.sdslabs.co/users/shagun.json. Using browser/Python’s Requests library leads to an authentication error, but curl seems to work fine. curl http://erdos.sdslabs.co/users/shagun.json returns the JSON response. Why would the curl request work while a normal browser or Requests-based request fail? Asked By: Shagun …

Total answers: 5