diff --git a/src/GitHub/Repos/Item/Item/Actions/Workflows/Item/Dispatches/DispatchesPostResponse.cs b/src/GitHub/Repos/Item/Item/Actions/Workflows/Item/Dispatches/DispatchesPostResponse.cs
new file mode 100644
index 000000000..273133df3
--- /dev/null
+++ b/src/GitHub/Repos/Item/Item/Actions/Workflows/Item/Dispatches/DispatchesPostResponse.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Microsoft.Kiota.Abstractions.Serialization;
+
+namespace GitHub.Repos.Item.Item.Actions.Workflows.Item.Dispatches;
+
+///
+/// Response from workflow dispatch when return_run_details is true.
+///
+public class DispatchesPostResponse : IParsable
+{
+ /// The workflow run ID.
+ public long? WorkflowRunId { get; set; }
+
+ /// The API URL for the workflow run.
+#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
+#nullable enable
+ public string? RunUrl { get; set; }
+#nullable restore
+#else
+ public string RunUrl { get; set; }
+#endif
+
+ /// The HTML URL for the workflow run.
+#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
+#nullable enable
+ public string? HtmlUrl { get; set; }
+#nullable restore
+#else
+ public string HtmlUrl { get; set; }
+#endif
+
+ public static DispatchesPostResponse CreateFromDiscriminatorValue(IParseNode parseNode)
+ {
+ _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
+ return new DispatchesPostResponse();
+ }
+
+ public IDictionary> GetFieldDeserializers()
+ {
+ return new Dictionary>
+ {
+ { "workflow_run_id", n => { WorkflowRunId = n.GetLongValue(); } },
+ { "run_url", n => { RunUrl = n.GetStringValue(); } },
+ { "html_url", n => { HtmlUrl = n.GetStringValue(); } },
+ };
+ }
+
+ public void Serialize(ISerializationWriter writer)
+ {
+ _ = writer ?? throw new ArgumentNullException(nameof(writer));
+ writer.WriteLongValue("workflow_run_id", WorkflowRunId);
+ writer.WriteStringValue("run_url", RunUrl);
+ writer.WriteStringValue("html_url", HtmlUrl);
+ }
+}
diff --git a/src/GitHub/Repos/Item/Item/Actions/Workflows/Item/Dispatches/DispatchesRequestBuilder.cs b/src/GitHub/Repos/Item/Item/Actions/Workflows/Item/Dispatches/DispatchesRequestBuilder.cs
index 2315fa345..516f9a9eb 100644
--- a/src/GitHub/Repos/Item/Item/Actions/Workflows/Item/Dispatches/DispatchesRequestBuilder.cs
+++ b/src/GitHub/Repos/Item/Item/Actions/Workflows/Item/Dispatches/DispatchesRequestBuilder.cs
@@ -41,16 +41,16 @@ public DispatchesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) :
/// Configuration for the request such as headers, query parameters, and middleware options.
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
- public async Task PostAsync(global::GitHub.Repos.Item.Item.Actions.Workflows.Item.Dispatches.DispatchesPostRequestBody body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default)
+ public async Task PostAsync(global::GitHub.Repos.Item.Item.Actions.Workflows.Item.Dispatches.DispatchesPostRequestBody body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default)
{
#nullable restore
#else
- public async Task PostAsync(global::GitHub.Repos.Item.Item.Actions.Workflows.Item.Dispatches.DispatchesPostRequestBody body, Action> requestConfiguration = default, CancellationToken cancellationToken = default)
+ public async Task PostAsync(global::GitHub.Repos.Item.Item.Actions.Workflows.Item.Dispatches.DispatchesPostRequestBody body, Action> requestConfiguration = default, CancellationToken cancellationToken = default)
{
#endif
_ = body ?? throw new ArgumentNullException(nameof(body));
var requestInfo = ToPostRequestInformation(body, requestConfiguration);
- await RequestAdapter.SendNoContentAsync(requestInfo, default, cancellationToken).ConfigureAwait(false);
+ return await RequestAdapter.SendAsync(requestInfo, global::GitHub.Repos.Item.Item.Actions.Workflows.Item.Dispatches.DispatchesPostResponse.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false);
}
///
/// You can use this endpoint to manually trigger a GitHub Actions workflow run. You can replace `workflow_id` with the workflow file name. For example, you could use `main.yaml`.You must configure your GitHub Actions workflow to run when the [`workflow_dispatch` webhook](/developers/webhooks-and-events/webhook-events-and-payloads#workflow_dispatch) event occurs. The `inputs` are configured in the workflow file. For more information about how to configure the `workflow_dispatch` event in the workflow file, see "[Events that trigger workflows](/actions/reference/events-that-trigger-workflows#workflow_dispatch)."OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
diff --git a/test/Dispatches/DispatchesRequestBuilderTest.cs b/test/Dispatches/DispatchesRequestBuilderTest.cs
new file mode 100644
index 000000000..7e0a0574b
--- /dev/null
+++ b/test/Dispatches/DispatchesRequestBuilderTest.cs
@@ -0,0 +1,72 @@
+using GitHub.Repos.Item.Item.Actions.Workflows.Item.Dispatches;
+using Microsoft.Kiota.Abstractions;
+using Microsoft.Kiota.Abstractions.Serialization;
+using Moq;
+using Xunit;
+
+public class DispatchesRequestBuilderTests
+{
+ private static (DispatchesRequestBuilder builder, Mock mockAdapter) CreateBuilder()
+ {
+ var mockAdapter = new Mock();
+ var mockSerializationWriterFactory = new Mock();
+ var mockSerializationWriter = new Mock();
+ mockSerializationWriterFactory
+ .Setup(f => f.GetSerializationWriter(It.IsAny()))
+ .Returns(mockSerializationWriter.Object);
+ mockAdapter
+ .Setup(a => a.SerializationWriterFactory)
+ .Returns(mockSerializationWriterFactory.Object);
+
+ var builder = new DispatchesRequestBuilder(new Dictionary
+ {
+ { "baseurl", "https://api.github.com" },
+ { "owner%2Did", "org" },
+ { "repo%2Did", "repo" },
+ { "workflow_id", "main.yml" },
+ }, mockAdapter.Object);
+
+ return (builder, mockAdapter);
+ }
+
+ [Fact]
+ public async Task PostAsync_ReturnsDispatchResponse()
+ {
+ var (builder, mockAdapter) = CreateBuilder();
+
+ var expectedResponse = new DispatchesPostResponse
+ {
+ WorkflowRunId = 22725043315,
+ RunUrl = "https://api.github.com/repos/org/repo/actions/runs/22725043315",
+ HtmlUrl = "https://github.com/org/repo/actions/runs/22725043315",
+ };
+
+ mockAdapter
+ .Setup(a => a.SendAsync(
+ It.IsAny(),
+ It.IsAny>(),
+ It.IsAny>>(),
+ It.IsAny()))
+ .ReturnsAsync(expectedResponse);
+
+ var body = new DispatchesPostRequestBody
+ {
+ Ref = "main",
+ AdditionalData = { ["return_run_details"] = true },
+ };
+
+ var result = await builder.PostAsync(body);
+
+ Assert.NotNull(result);
+ Assert.Equal(22725043315, result!.WorkflowRunId);
+ Assert.Equal("https://api.github.com/repos/org/repo/actions/runs/22725043315", result.RunUrl);
+ Assert.Equal("https://github.com/org/repo/actions/runs/22725043315", result.HtmlUrl);
+ }
+
+ [Fact]
+ public async Task PostAsync_ThrowsOnNullBody()
+ {
+ var (builder, _) = CreateBuilder();
+ await Assert.ThrowsAsync(() => builder.PostAsync(null!));
+ }
+}