diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs index 6b0bdf89b09..1705e9e1c99 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs @@ -180,7 +180,6 @@ public async Task AddSanitizers() { var registeredId = _recordingHandler.RegisterSanitizer(sanitizer, recordingId); registeredSanitizers.Add(registeredId); - Response.Headers.Add("x-recording-id", recordingId); } else { @@ -188,6 +187,12 @@ public async Task AddSanitizers() registeredSanitizers.Add(registeredId); } } + + if (recordingId != null) + { + Response.Headers.Add("x-recording-id", recordingId); + } + var json = JsonSerializer.Serialize(new { Sanitizers = registeredSanitizers }); Response.ContentType = "application/json"; Response.ContentLength = json.Length;