The Free Software Media System - Server Backend & API
Use PostAsJsonAsync where possible
Bond_00940be86eec0fa
diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.csindex 8a03583bb2..4c46933aab 100644--- a/tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.cs+++ b/tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.cs@@ -63,8 +63,7 @@ namespace Jellyfin.Server.Integration.Tests.ControllersName = "ThisProfileDoesNotExist"};- using var content = JsonContent.Create(deviceProfile, options: _jsonOptions);- using var getResponse = await client.PostAsync("/Dlna/Profiles/" + NonExistentProfile, content).ConfigureAwait(false);+ using var getResponse = await client.PostAsJsonAsync("/Dlna/Profiles/" + NonExistentProfile, deviceProfile, _jsonOptions).ConfigureAwait(false);Assert.Equal(HttpStatusCode.NotFound, getResponse.StatusCode);}@@ -80,8 +79,7 @@ namespace Jellyfin.Server.Integration.Tests.ControllersName = "ThisProfileIsNew"};- using var content = JsonContent.Create(deviceProfile, options: _jsonOptions);- using var getResponse = await client.PostAsync("/Dlna/Profiles", content).ConfigureAwait(false);+ using var getResponse = await client.PostAsJsonAsync("/Dlna/Profiles", deviceProfile, _jsonOptions).ConfigureAwait(false);Assert.Equal(HttpStatusCode.NoContent, getResponse.StatusCode);}@@ -119,8 +117,7 @@ namespace Jellyfin.Server.Integration.Tests.ControllersId = _newDeviceProfileId};- using var content = JsonContent.Create(updatedProfile, options: _jsonOptions);- using var getResponse = await client.PostAsync("/Dlna/Profiles", content).ConfigureAwait(false);+ using var getResponse = await client.PostAsJsonAsync("/Dlna/Profiles", updatedProfile, _jsonOptions).ConfigureAwait(false);Assert.Equal(HttpStatusCode.NoContent, getResponse.StatusCode);}diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.csindex a9713b4cb8..2da5237db2 100644--- a/tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.cs+++ b/tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.cs@@ -72,8 +72,7 @@ namespace Jellyfin.Server.Integration.Tests.ControllersPath = "/this/path/doesnt/exist"};- using var postContent = JsonContent.Create(data, options: _jsonOptions);- var response = await client.PostAsync("Library/VirtualFolders/Paths", postContent).ConfigureAwait(false);+ var response = await client.PostAsJsonAsync("Library/VirtualFolders/Paths", data, _jsonOptions).ConfigureAwait(false);Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);}@@ -90,8 +89,7 @@ namespace Jellyfin.Server.Integration.Tests.ControllersPathInfo = new MediaPathInfo("test")};- using var postContent = JsonContent.Create(data, options: _jsonOptions);- var response = await client.PostAsync("Library/VirtualFolders/Paths/Update", postContent).ConfigureAwait(false);+ var response = await client.PostAsJsonAsync("Library/VirtualFolders/Paths/Update", data, _jsonOptions).ConfigureAwait(false);Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);}diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/StartupControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/StartupControllerTests.csindex d9cde1dd96..ed92ce25a4 100644--- a/tests/Jellyfin.Server.Integration.Tests/Controllers/StartupControllerTests.cs+++ b/tests/Jellyfin.Server.Integration.Tests/Controllers/StartupControllerTests.cs@@ -37,8 +37,7 @@ namespace Jellyfin.Server.Integration.Tests.ControllersPreferredMetadataLanguage = "nl"};- using var postContent = JsonContent.Create(config, options: _jsonOptions);- using var postResponse = await client.PostAsync("/Startup/Configuration", postContent).ConfigureAwait(false);+ using var postResponse = await client.PostAsJsonAsync("/Startup/Configuration", config, _jsonOptions).ConfigureAwait(false);Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);using var getResponse = await client.GetAsync("/Startup/Configuration").ConfigureAwait(false);@@ -80,8 +79,7 @@ namespace Jellyfin.Server.Integration.Tests.ControllersPassword = "NewPassword"};- using var postContent = JsonContent.Create(user, options: _jsonOptions);- var postResponse = await client.PostAsync("/Startup/User", postContent).ConfigureAwait(false);+ var postResponse = await client.PostAsJsonAsync("/Startup/User", user, _jsonOptions).ConfigureAwait(false);Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);var getResponse = await client.GetAsync("/Startup/User").ConfigureAwait(false);diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/UserControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/UserControllerTests.csindex 0f8b930f14..f11f276f80 100644--- a/tests/Jellyfin.Server.Integration.Tests/Controllers/UserControllerTests.cs+++ b/tests/Jellyfin.Server.Integration.Tests/Controllers/UserControllerTests.cs@@ -32,16 +32,10 @@ namespace Jellyfin.Server.Integration.Tests.Controllers}private Task<HttpResponseMessage> CreateUserByName(HttpClient httpClient, CreateUserByName request)- {- using var postContent = JsonContent.Create(request, options: _jsonOpions);- return httpClient.PostAsync("Users/New", postContent);- }+ => httpClient.PostAsJsonAsync("Users/New", request, _jsonOpions);private Task<HttpResponseMessage> UpdateUserPassword(HttpClient httpClient, Guid userId, UpdateUserPassword request)- {- using var postContent = JsonContent.Create(request, options: _jsonOpions);- return httpClient.PostAsync("Users/" + userId.ToString("N", CultureInfo.InvariantCulture) + "/Password", postContent);- }+ => httpClient.PostAsJsonAsync("Users/" + userId.ToString("N", CultureInfo.InvariantCulture) + "/Password", request, _jsonOpions);[Fact][Priority(-1)]