Skip to content

Commit

Permalink
Fix SendHttpRequest activity
Browse files Browse the repository at this point in the history
Fixes an issue where an exception occurs when no content is provided
  • Loading branch information
sfmskywalker committed Jan 23, 2023
1 parent 4f5bc70 commit b7a9607
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/modules/Elsa.Http/Activities/SendHttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@ private HttpRequestMessage PrepareRequest(ActivityExecutionContext context)
request.Headers.Add(header.Key, header.Value.AsEnumerable());

var contentType = ContentType.TryGet(context);
var contentWriters = context.GetServices<IHttpContentWriter>();
var contentWriter = SelectContentWriter(contentType, contentWriters);
var content = Content.TryGet(context);
request.Content = contentWriter.GetContent(content, contentType);

if (contentType != null && content != null)
{
var contentWriters = context.GetServices<IHttpContentWriter>();
var contentWriter = SelectContentWriter(contentType, contentWriters);
request.Content = contentWriter.GetContent(content, contentType);
}

return request;
}
Expand Down

0 comments on commit b7a9607

Please sign in to comment.