requests.Request model, , data:
some_request = Request(method, url, headers=headers)
if
some_request.data = data
, , , , , data.
:
, , , prepared_request. , prepared_request , prepare, ? , , , , , ?
, , , :
def fetch_from_api(self):
s = Session()
headers = { "Authorization" : REST_API_AUTHORIZATION_HEADER}
_request = Request(self.method, self.url_for_api, headers=headers)
if self.method in ['POST', 'PATCH', 'PUT']:
headers['content-type'] = 'application/x-www-form-urlencoded'
_request.data = self.postdata
prepped = _request.prepare()
self.api_response = s.send(prepped)
( . ? fetch_from_api, POST ing PUT ing data. , , .)
: , , , , . , , , .
, , , , , , , , , , .