@@ -50,9 +50,7 @@ public async Task<T> GetAsync<T>(
5050 {
5151 EnsureHttpClient ( ) ;
5252
53- string requestUri = queryParams == null ? uri : QueryHelpers . AddQueryString ( uri , queryParams ) ;
54-
55- var response = await SendAsync ( requestUri , HttpMethod . Get , headers , cancellationToken : cancellationToken ) ;
53+ var response = await SendAsync ( uri , HttpMethod . Get , queryParams , headers , cancellationToken : cancellationToken ) ;
5654
5755 return await response . ParseStreamAsync < T > ( serializerSettings ) ;
5856 }
@@ -79,10 +77,13 @@ private static async Task<Exception> BuildException(HttpResponseMessage response
7977 private async Task < HttpResponseMessage > SendAsync (
8078 string requestUri ,
8179 HttpMethod httpMethod ,
80+ IDictionary < string , string > queryParams = null ,
8281 IDictionary < string , string > headers = null ,
8382 Action < HttpRequestMessage > attachContent = null ,
8483 CancellationToken cancellationToken = default )
8584 {
85+ requestUri = AddQueryString ( requestUri , queryParams ) ;
86+
8687 HttpRequestMessage httpRequest = new HttpRequestMessage ( httpMethod , requestUri ) ;
8788 httpRequest . Headers . Authorization = new AuthenticationHeaderValue ( "Bearer" , _options . AuthToken ) ;
8889 httpRequest . Headers . Add ( "Notion-Version" , _options . NotionVersion ) ;
@@ -127,9 +128,7 @@ void AttachContent(HttpRequestMessage httpRequest)
127128 httpRequest . Content = new StringContent ( JsonConvert . SerializeObject ( body , defaultSerializerSettings ) , Encoding . UTF8 , "application/json" ) ;
128129 }
129130
130- string requestUri = queryParams == null ? uri : QueryHelpers . AddQueryString ( uri , queryParams ) ;
131-
132- var response = await SendAsync ( requestUri , HttpMethod . Post , headers , AttachContent , cancellationToken : cancellationToken ) ;
131+ var response = await SendAsync ( uri , HttpMethod . Post , queryParams , headers , AttachContent , cancellationToken : cancellationToken ) ;
133132
134133 return await response . ParseStreamAsync < T > ( serializerSettings ) ;
135134 }
@@ -144,9 +143,7 @@ void AttachContent(HttpRequestMessage httpRequest)
144143 httpRequest . Content = new StringContent ( serializedBody , Encoding . UTF8 , "application/json" ) ;
145144 }
146145
147- string requestUri = queryParams == null ? uri : QueryHelpers . AddQueryString ( uri , queryParams ) ;
148-
149- var response = await SendAsync ( requestUri , new HttpMethod ( "PATCH" ) , headers , AttachContent , cancellationToken : cancellationToken ) ;
146+ var response = await SendAsync ( uri , new HttpMethod ( "PATCH" ) , queryParams , headers , AttachContent , cancellationToken : cancellationToken ) ;
150147
151148 return await response . ParseStreamAsync < T > ( serializerSettings ) ;
152149 }
@@ -161,5 +158,10 @@ private HttpClient EnsureHttpClient()
161158
162159 return _httpClient ;
163160 }
161+
162+ private static string AddQueryString ( string uri , IDictionary < string , string > queryParams )
163+ {
164+ return queryParams == null ? uri : QueryHelpers . AddQueryString ( uri , queryParams ) ;
165+ }
164166 }
165167}
0 commit comments