@@ -124,24 +124,23 @@ def _create_request_message(self, http_method, location_id, route_values=None,
124124 route_values = {}
125125 route_values ['area' ] = location .area
126126 route_values ['resource' ] = location .resource_name
127- route_template = self ._remove_optional_route_parameters (location .route_template ,
128- route_values )
127+ url = self ._transform_route_template (location .route_template , route_values )
129128 logger .debug ('Route template: %s' , location .route_template )
130- url = self ._client .format_url (route_template , ** route_values )
131129 request = ClientRequest (method = http_method , url = self ._client .format_url (url ))
132130 if query_parameters :
133131 request .format_parameters (query_parameters )
134132 return request
135133
136134 @staticmethod
137- def _remove_optional_route_parameters (route_template , route_values ):
135+ def _transform_route_template (route_template , route_values ):
138136 new_template = ''
139137 route_template = route_template .replace ('{*' , '{' )
140138 for path_segment in route_template .split ('/' ):
141139 if (len (path_segment ) <= 2 or not path_segment [0 ] == '{'
142- or not path_segment [len (path_segment ) - 1 ] == '}'
143- or path_segment [1 :len (path_segment ) - 1 ] in route_values ):
140+ or not path_segment [len (path_segment ) - 1 ] == '}' ):
144141 new_template = new_template + '/' + path_segment
142+ elif path_segment [1 :len (path_segment ) - 1 ] in route_values :
143+ new_template = new_template + '/' + route_values [path_segment [1 :len (path_segment ) - 1 ]]
145144 return new_template
146145
147146 def _get_resource_location (self , location_id ):
@@ -222,7 +221,7 @@ def _negotiate_request_version(location, version):
222221 else :
223222 # We can send at the requested api version. Make sure the resource version
224223 # is not bigger than what the server supports
225- negotiated_version = str ( requested_api_version )
224+ negotiated_version = match . group ( 1 )
226225 is_preview = match .group (3 ) is not None
227226 if is_preview :
228227 negotiated_version += '-preview'
@@ -267,7 +266,7 @@ def _handle_error(self, request, response):
267266 raise AzureDevOpsAuthenticationError (full_message_format .format (error_message = error_message ,
268267 url = request .url ))
269268 else :
270- full_message_format = '{error_message}Operation returned an invalid status code of {status_code} .'
269+ full_message_format = '{error_message}Operation returned a {status_code} status code.'
271270 raise AzureDevOpsClientRequestError (full_message_format .format (error_message = error_message ,
272271 status_code = response .status_code ))
273272
0 commit comments