@@ -352,13 +352,13 @@ def send_external_request(n_clicks, connection, method, body, auth_type):
352352 return html .Div ([html .P ("Please fill in all required fields: Connection and Method" , className = "text-danger" )])
353353
354354 try :
355- headers = {}
355+ request_headers = {"Content-Type" : "application/json" }
356356
357357 # Parse body JSON
358- body_data = None
358+ request_data = None
359359 if body and body .strip ():
360360 try :
361- body_data = json .loads (body )
361+ request_data = json .loads (body )
362362 except json .JSONDecodeError :
363363 return html .Div ([html .P ("❌ Invalid JSON in body" , className = "text-danger" )])
364364 w = get_workspace_client (auth_type )
@@ -399,18 +399,19 @@ def send_external_request(n_clicks, connection, method, body, auth_type):
399399 return html .Div ([html .P (f"❌ MCP Initialization Error: { error } " , className = "text-danger" )])
400400 else :
401401 return html .Div ([html .P (f"❌ MCP Initialization Error: { error } " , className = "text-danger" )])
402+
402403 mcp_session_id = session_id
403404
404405 # Add MCP session ID to headers
405- headers ["Mcp-Session-Id" ] = mcp_session_id
406+ request_headers ["Mcp-Session-Id" ] = mcp_session_id
406407
407408 # Use json parameter for MCP requests
408409 response = w .serving_endpoints .http_request (
409410 conn = connection ,
410411 method = method_enum ,
411412 path = request_path ,
412- headers = headers ,
413- json = body_data
413+ headers = request_headers if request_headers else None ,
414+ json = request_data if request_data else {},
414415 )
415416 else :
416417 # Regular requests
@@ -419,15 +420,16 @@ def send_external_request(n_clicks, connection, method, body, auth_type):
419420 conn = connection ,
420421 method = method_enum ,
421422 path = request_path ,
422- headers = headers ,
423- json = body_data
423+ headers = request_headers if request_headers else None ,
424+ json = request_data if request_data else {},
424425 )
425426 else :
426427 response = w .serving_endpoints .http_request (
427428 conn = connection ,
428429 method = method_enum ,
429430 path = request_path ,
430- headers = headers
431+ headers = request_headers if request_headers else None ,
432+ json = request_data if request_data else {},
431433 )
432434
433435 response_json = response .json ()
0 commit comments