We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2e152ec commit 2b3fc02Copy full SHA for 2b3fc02
src/RestSharp/Request/RequestContent.cs
@@ -142,9 +142,10 @@ void AddHeaders() {
142
.Where(x => x.Type == ParameterType.HttpHeader && ContentHeaders.Contains(x.Name))
143
.ToArray();
144
145
- if (contentHeaders.Length > 0 && Content == null)
146
- throw new InvalidRequestException("Content headers should not be used when there's no body in the request");
147
-
+ if (contentHeaders.Length > 0 && Content == null) {
+ // We need some content to add content headers to it, so if necessary, we'll add empty content
+ Content = new StringContent("");
148
+ }
149
contentHeaders.ForEach(AddHeader);
150
151
void AddHeader(Parameter parameter) {
0 commit comments