@@ -33,6 +33,9 @@ public interface IRestApiClient
3333
3434 Task < RestApiResponse < T > > PostAsync < T > ( string path , HttpContent content ) ;
3535
36+ Task < RestApiResponse < T > > PostAsync < T > ( string path , HttpContent content , Dictionary < string , string > headers ,
37+ MediaTypeWithQualityHeaderValue acceptHeader ) ;
38+
3639 Task < RestApiResponse > PostAsync ( string path , string accessToken , HttpContent content ) ;
3740
3841 Task < RestApiResponse < T > > PostAsync < T > ( string path , string accessToken , HttpContent content ) ;
@@ -104,6 +107,10 @@ public Task<RestApiResponse> PostAsync(string path, HttpContent content)
104107 public Task < RestApiResponse < T > > PostAsync < T > ( string path , HttpContent content )
105108 => ExecAsync < T > ( BuildRequest ( HttpMethod . Post , path , string . Empty , content ) ) ;
106109
110+ public Task < RestApiResponse < T > > PostAsync < T > ( string path , HttpContent content , Dictionary < string , string > headers ,
111+ MediaTypeWithQualityHeaderValue acceptHeader )
112+ => ExecAsync < T > ( BuildRequest ( HttpMethod . Post , path , string . Empty , content , null , headers , acceptHeader ) ) ;
113+
107114 public Task < RestApiResponse > PostAsync ( string path , string accessToken , HttpContent content )
108115 => ExecAsync ( BuildRequest ( HttpMethod . Post , path , accessToken , content ) ) ;
109116
@@ -151,11 +158,13 @@ private HttpRequestMessage BuildRequest(
151158 string path ,
152159 string accessToken ,
153160 Option < HttpContent > httpContent ,
154- string ? rowVersion = null )
161+ string ? rowVersion = null ,
162+ Dictionary < string , string > ? headers = null ,
163+ MediaTypeWithQualityHeaderValue ? acceptHeader = null )
155164 {
156165 HttpRequestMessage request = new HttpRequestMessage ( method , path ) ;
157166
158- request . Headers . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "application/json" ) ) ;
167+ request . Headers . Accept . Add ( acceptHeader ?? new MediaTypeWithQualityHeaderValue ( "application/json" ) ) ;
159168
160169 if ( ! string . IsNullOrEmpty ( accessToken ) )
161170 {
@@ -166,6 +175,14 @@ private HttpRequestMessage BuildRequest(
166175 {
167176 request . Headers . TryAddWithoutValidation ( "If-Match" , rowVersion ) ;
168177 }
178+
179+ if ( headers != null )
180+ {
181+ foreach ( var header in headers )
182+ {
183+ request . Headers . TryAddWithoutValidation ( header . Key , header . Value ) ;
184+ }
185+ }
169186
170187 if ( httpContent . IsSome )
171188 {
0 commit comments