when i make the call without session.mount() it returns what i need and 200 ok but if i try with session.mount as in the code below it is returning 400 bad request
gateway = ApiGateway("https://redsky.target.com/redsky_aggregations/v1/web/plp_search_v2", access_key_id=aws_access_key_id, access_key_secret=aws_secret_access_id, regions=EXTRA_REGIONS)
url = "https://redsky.target.com/redsky_aggregations/v1/web/plp_search_v2"
header={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) \
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36'}
params = {
"key": "9f36aeafbe60771e321a7cc95a78140772ab3e96",
"category": "ziogr",
"channel": "WEB",
"count": "24",
"default_purchasability_filter": "true",
"include_sponsored": "false",
"offset": f"{offset}",
"page": f"/c/ziogr",
"pricing_store_id": f"2272",
"store_ids": f"2272",
"visitor_id": "22069",
}
session = requests.Session()
session.mount("https://", gateway)
session.mount("http://", gateway)
response = session.get(url, params=params, headers=header)
I am trying to use the API Gateway from AWS to make calls to that URI and i don't know why without the sessions.mount lines it is working
CodePudding user response:
I used url parse lib to delete the path from the url and after that re do the gateway mount into the session
It is like this
url = "https://redsky.target.com/redsky_aggregations/v1/web/plp_search_v2"
src_parsed = urlparse(url)
src_nopath = "%s://%s" % (src_parsed.scheme, src_parsed.netloc)
session = requests.Session()
session.mount(src_nopath, gateway)
response = session.get(url, stream=True, params=params, headers=header)