@@ -51,7 +51,7 @@ public class Client(string apiKey, Blog blog, string baseUrl = "https://rest.aki
51
51
/// <returns>A value indicating whether the specified comment is spam.</returns>
52
52
/// <exception cref="HttpRequestException">The remote server returned an invalid response.</exception>
53
53
public async Task < CheckResult > CheckComment ( Comment comment , CancellationToken cancellationToken = default ) {
54
- using var response = await Fetch ( "1.1/comment-check" , comment . ToJson ( ) , cancellationToken ) ;
54
+ using var response = await Fetch ( "1.1/comment-check" , comment . ToDictionary ( ) , cancellationToken ) ;
55
55
if ( await response . Content . ReadAsStringAsync ( cancellationToken ) == "false" ) return CheckResult . Ham ;
56
56
if ( ! response . Headers . TryGetValues ( "X-akismet-pro-tip" , out var proTips ) ) return CheckResult . Spam ;
57
57
return proTips . First ( ) == "discard" ? CheckResult . PervasiveSpam : CheckResult . Spam ;
@@ -65,7 +65,7 @@ public async Task<CheckResult> CheckComment(Comment comment, CancellationToken c
65
65
/// <returns>Completes once the comment has been submitted.</returns>
66
66
/// <exception cref="HttpRequestException">The remote server returned an invalid response.</exception>
67
67
public async Task SubmitHam ( Comment comment , CancellationToken cancellationToken = default ) {
68
- using var response = await Fetch ( "1.1/submit-ham" , comment . ToJson ( ) , cancellationToken ) ;
68
+ using var response = await Fetch ( "1.1/submit-ham" , comment . ToDictionary ( ) , cancellationToken ) ;
69
69
var body = await response . Content . ReadAsStringAsync ( cancellationToken ) ;
70
70
if ( body != Success ) throw new HttpRequestException ( "Invalid server response." ) ;
71
71
}
@@ -78,7 +78,7 @@ public async Task SubmitHam(Comment comment, CancellationToken cancellationToken
78
78
/// <returns>Completes once the comment has been submitted.</returns>
79
79
/// <exception cref="HttpRequestException">The remote server returned an invalid response.</exception>
80
80
public async Task SubmitSpam ( Comment comment , CancellationToken cancellationToken = default ) {
81
- using var response = await Fetch ( "1.1/submit-spam" , comment . ToJson ( ) , cancellationToken ) ;
81
+ using var response = await Fetch ( "1.1/submit-spam" , comment . ToDictionary ( ) , cancellationToken ) ;
82
82
var body = await response . Content . ReadAsStringAsync ( cancellationToken ) ;
83
83
if ( body != Success ) throw new HttpRequestException ( "Invalid server response." ) ;
84
84
}
@@ -107,7 +107,7 @@ public async Task<bool> VerifyKey(CancellationToken cancellationToken = default)
107
107
/// <returns>The server response.</returns>
108
108
/// <exception cref="HttpRequestException">An error occurred while querying the end point.</exception>
109
109
private async Task < HttpResponseMessage > Fetch ( string endpoint , IDictionary < string , string > ? fields = null , CancellationToken cancellationToken = default ) {
110
- var postFields = Blog . ToJson ( ) ;
110
+ var postFields = Blog . ToDictionary ( ) ;
111
111
postFields . Add ( "api_key" , ApiKey ) ;
112
112
if ( IsTest ) postFields . Add ( "is_test" , "1" ) ;
113
113
if ( fields is not null ) foreach ( var item in fields ) postFields . Add ( item . Key , item . Value ) ;
0 commit comments