#NEWLINE# def json_request( self , method , url , content_type = 'application/json' , **kwargs ) : #NEWLINE# #INDENT# kwargs . setdefault ( 'headers' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# kwargs [ 'headers' ] . setdefault ( 'Content-Type' , content_type ) #NEWLINE# if ( 'body' in kwargs ) : #NEWLINE# #INDENT# if ( 'data' in kwargs ) : #NEWLINE# #INDENT# raise ValueError ( "Can't provide both 'data' and 'body' to a request" ) #NEWLINE# #UNINDENT# LOG . warning ( "Use of 'body' is deprecated; use 'data' instead" ) #NEWLINE# kwargs [ 'data' ] = kwargs . pop ( 'body' ) #NEWLINE# #UNINDENT# if ( 'data' in kwargs ) : #NEWLINE# #INDENT# kwargs [ 'data' ] = jsonutils . dumps ( kwargs [ 'data' ] ) #NEWLINE# #UNINDENT# resp = self . _http_request ( kwargs , method , ** kwargs ) #NEWLINE# body = resp . content #NEWLINE# if ( 'application/json' in resp . headers . get ( 'content-type' , [ ] ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# body = resp . json ( ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# LOG . error ( 'Could not decode response body as JSON' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# body = None #NEWLINE# #UNINDENT# return ( resp , body )