curl

curl to python requests conversion for solr query

curl to python requests conversion for solr query Question: I have a bit of a bizzare problem. I have a solr index, which I query using curl like so: curl ‘http://localhost:8984/solr/my_index/select?indent=on&q="galvin%20life%20sciences"~0&wt=json&sort=_docid_%20desc&rows=5’ and I get (note the q string and the tilde operator which I use for proximity search): { "responseHeader":{ "status":0, "QTime":1, "params":{ "q":""galvin life …

Total answers: 1

FastAPI GET endpoint returns "405 method not allowed" response

FastAPI GET endpoint returns "405 method not allowed" response Question: A GET endpoint in FastAPI is returning correct result, but returns 405 method not allowed when curl -I is used. This is happening with all the GET endpoints. As a result, the application is working, but health check on application from a load balancer is …

Total answers: 2

What do I need to change so my tornado code can post successfully?

What do I need to change so my tornado code can post successfully? Question: I have the following (with some strings modified) which works when using the requests library. import requests from pprint import pprint import json PEM = ‘/full/path/to/my.pem’ client_id=’cliendID’ client_secret=’clientSecret’ USER=’myuser’ PSWD=’mypwd’ url = ‘https://theurl.com/request/’ data = { "grant_type": "password", "username": USER, "password": …

Total answers: 1

Send JSON from curl by POST to Python FastAPI

Send JSON from curl by POST to Python FastAPI Question: I’m running the following script: from fastapi import FastAPI from fastapi import Request import os import uvicorn app = FastAPI() @app.post("/") async def root(data: Request): try: res = await data.json() except Exception as ex: res = str(ex) return res if __name__ == "__main__": prog = …

Total answers: 1

How do I use multiple variables and strings within an os.system() command?

How do I use multiple variables and strings within an os.system() command? Question: im trying to make a simple program that downloads a file. im having a problem with the command part. here is the code: import os #gather user input print("hello! welcome to the website dowloader! paste in the url(including the http part) and …

Total answers: 1

Elasticsearch Search Query using python subprocess: Illegal Argument Exception

Elasticsearch Search Query using python subprocess: Illegal Argument Exception Question: I am trying to run a curl command using the run command in the subprocess module in python. But it is failing. However, the curl command for my elasticsearch search query API is working fine- curl -k XGET -H "Content-Type: application/json" -H "Authorization: ApiKey Q2txZ2FvSUJ6Nlcwa3pjbnh0NUM6enBidjdNLTdRQVNhc0tuTEk5UEZmZw==" …

Total answers: 1

Why does this proxy require authentication when used from curl but not from python requests?

Why does this proxy require authentication when used from curl but not from python requests? Question: I’m using https://github.com/abhinavsingh/proxy.py, setting it up with basic auth like so: proxy –basic-auth "user:pass" When I use it with curl, it requires proxy auth as expected: curl -I -x localhost:8899 http://example.com => 407 curl -I -x user:pass@localhost:8899 http://example.com => …

Total answers: 1

length of list read from a csv varies, depending on when a read is performed

length of list read from a csv varies, depending on when a read is performed Question: I’m trying to write a simple function that reads in a csv and stores its content inside a list and either returns said list formatted or a string containing the information on why the csv is empty. For clarification, …

Total answers: 1

Why is this requests get not working with this url

Why is this requests get not working with this url Question: If i run this Python code my program just hangs up. (I don`t get any error.) import requests url = "https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/generative/dcgan.ipynb" r = requests.get(url) But this works perfectly fine as expected. import requests url = "https://stackoverflow.com" r = requests.get(url) Using curl to get the …

Total answers: 3

How to set shopify order to fulfilled?

How to set shopify order to fulfilled? Question: Set-up I have a Shopify store with an unfulfilled order and have access to the store’s REST API. The order has been shipped and I have its tracking_number, tracking_url and the transport_company. I want to use the REST API to set the order to fulfilled and send …

Total answers: 2