@@ -15,7 +15,7 @@ internal class MessageRequestBuilder : IMessageRequestBuilder
15
15
private readonly Dictionary < string , string > pathMapper ;
16
16
private readonly Dictionary < string , string > headerMapper ;
17
17
private readonly Dictionary < string , string > queryMapper ;
18
- private string content = string . Empty ;
18
+ private string ? content ;
19
19
20
20
public MessageRequestBuilder ( string pathTemplate , IContractSerializer serializer )
21
21
{
@@ -24,6 +24,7 @@ public MessageRequestBuilder(string pathTemplate, IContractSerializer serializer
24
24
pathMapper = new Dictionary < string , string > ( StringComparer . Ordinal ) ;
25
25
headerMapper = new Dictionary < string , string > ( StringComparer . Ordinal ) ;
26
26
queryMapper = new Dictionary < string , string > ( StringComparer . Ordinal ) ;
27
+ WithHeaderParameter ( "accept" , "application/json" ) ;
27
28
}
28
29
29
30
public HttpRequestMessage Build ( HttpMethod method )
@@ -37,10 +38,14 @@ public HttpRequestMessage Build(HttpMethod method)
37
38
}
38
39
39
40
message . RequestUri = BuildRequestUri ( ) ;
40
- message . Content = new StringContent ( content ) ;
41
- message . Content . Headers . ContentType = MediaTypeHeaderValue . Parse ( "application/json" ) ;
42
41
message . Method = method ;
43
42
43
+ if ( content is not null )
44
+ {
45
+ message . Content = new StringContent ( content ) ;
46
+ message . Content . Headers . ContentType = MediaTypeHeaderValue . Parse ( "application/json" ) ;
47
+ }
48
+
44
49
return message ;
45
50
}
46
51
@@ -126,4 +131,4 @@ private Uri BuildRequestUri()
126
131
return new Uri ( urlBuilder . ToString ( ) , UriKind . RelativeOrAbsolute ) ;
127
132
}
128
133
}
129
- }
134
+ }
0 commit comments