File tree Expand file tree Collapse file tree
PortaCapena.OdooJsonRpcClient Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,10 +17,16 @@ namespace PortaCapena.OdooJsonRpcClient
1717{
1818 public sealed class OdooClient
1919 {
20- private static HttpClient _client = new HttpClient ( ) ;
20+ private static HttpClient _client ;
2121 public OdooConfig Config { get ; }
2222
2323 [ ThreadStatic ] private static int ? _userUid ;
24+
25+ static OdooClient ( ) {
26+ _client = new HttpClient ( ) ;
27+ _client . DefaultRequestHeaders . Accept . Clear ( ) ;
28+ _client . DefaultRequestHeaders . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "application/json" ) ) ;
29+ }
2430
2531 public OdooClient ( OdooConfig config )
2632 {
@@ -256,8 +262,6 @@ public static async Task<HttpResponseMessage> CallAsync(OdooRequestModel request
256262 var json = JsonConvert . SerializeObject ( requestModel , new IsoDateTimeConverter { DateTimeFormat = OdooConsts . DateTimeFormat } ) ;
257263 var data = new StringContent ( json , Encoding . UTF8 , "application/json" ) ;
258264
259- _client . DefaultRequestHeaders . Accept . Clear ( ) ;
260- _client . DefaultRequestHeaders . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "application/json" ) ) ;
261265 var result = await _client . PostAsync ( requestModel . Params . Url , data ) ;
262266 return result ;
263267 }
You can’t perform that action at this time.
0 commit comments