write a function that makes an http post call to localhost:7071 with the body parameters "ticketnumber","ticketsystem","username","oid","justification" in csharp

main.cs
using System.Net.Http;
using System.Threading.Tasks;

// Define the parameters for the request
var ticketNumber = "12345";
var ticketSystem = "ABC";
var userName = "JohnDoe";
var oid = "67890";
var justification = "Need access to XYZ system";

async Task<HttpResponseMessage> PostToApiAsync()
{
    using (var client = new HttpClient())
    {
        var values = new Dictionary<string, string>
        {
            { "ticketnumber", ticketNumber },
            { "ticketsystem", ticketSystem },
            { "username", userName },
            { "oid", oid },
            { "justification", justification }
        };

        var content = new FormUrlEncodedContent(values);

        var response = await client.PostAsync("http://localhost:7071", content);

        return response;
    }
}
795 chars
31 lines

Call the function using PostToApiAsync().Result.

gistlibby LogSnag