def build_request_with_data(url, data, api_key, method):
 http_redirect_with_data_handler = HTTPRedirectWithDataHandler(method=method)
 opener = urllib2.build_opener(http_redirect_with_data_handler)
 urllib2.install_opener(opener)
 url = make_url(url, api_key=api_key, args=None)
 request = urllib2.Request(url, headers={'Content-Type': 'application/json'}, data=json.dumps(data))
 request_method = request.get_method()
 if (request_method != method):
  request.get_method = (lambda : method)
 return (opener, request)

def build_request_with_data ( url , data , api_key , method ) : http_redirect_with_data_handler = HTTPRedirectWithDataHandler ( method = method ) opener = urllib2 . build_opener ( http_redirect_with_data_handler ) urllib2 . install_opener ( opener ) url = make_url ( url , api_key = api_key , args = None ) request = urllib2 . Request ( url , headers = { 'Content-Type' : 'application/json' } , data = json . dumps ( data ) ) request_method = request . get_method ( ) if ( request_method != method ) : request . get_method = ( lambda : method ) return ( opener , request )
build a request with the received method .