44using GitVersion . OutputVariables ;
55using GitVersion . Logging ;
66using Newtonsoft . Json ;
7+ using System . Text ;
78
89namespace GitVersion . BuildServers
910{
@@ -28,8 +29,9 @@ public override string GenerateSetVersionMessage(VersionVariables variables)
2829 version = $ "{ variables . FullSemVer } .build.{ buildNumber } ",
2930 } ;
3031
31- var stringContent = new StringContent ( JsonConvert . SerializeObject ( body ) ) ;
32- httpClient . PutAsync ( "api/build" , stringContent ) . Wait ( ) ;
32+ var stringContent = new StringContent ( JsonConvert . SerializeObject ( body ) , Encoding . UTF8 , "application/json" ) ;
33+ var response = httpClient . PutAsync ( "api/build" , stringContent ) . GetAwaiter ( ) . GetResult ( ) ;
34+ response . EnsureSuccessStatusCode ( ) ;
3335
3436 return $ "Set AppVeyor build number to '{ variables . FullSemVer } '.";
3537 }
@@ -44,8 +46,9 @@ public override string[] GenerateSetParameterMessage(string name, string value)
4446 value = $ "{ value } "
4547 } ;
4648
47- var stringContent = new StringContent ( JsonConvert . SerializeObject ( body ) ) ;
48- httpClient . PostAsync ( "api/build/variables" , stringContent ) . Wait ( ) ;
49+ var stringContent = new StringContent ( JsonConvert . SerializeObject ( body ) , Encoding . UTF8 , "application/json" ) ;
50+ var response = httpClient . PostAsync ( "api/build/variables" , stringContent ) . GetAwaiter ( ) . GetResult ( ) ;
51+ response . EnsureSuccessStatusCode ( ) ;
4952
5053 return new [ ]
5154 {
@@ -55,12 +58,11 @@ public override string[] GenerateSetParameterMessage(string name, string value)
5558
5659 private HttpClient GetHttpClient ( )
5760 {
58- var headerValue = new MediaTypeWithQualityHeaderValue ( "application/json" ) ;
5961 var httpClient = new HttpClient
6062 {
6163 BaseAddress = new Uri ( Environment . GetEnvironmentVariable ( "APPVEYOR_API_URL" ) )
6264 } ;
63- httpClient . DefaultRequestHeaders . Accept . Add ( headerValue ) ;
65+
6466 return httpClient ;
6567 }
6668
0 commit comments