Here is my Example how to post Joomla! article from .NET.

Four steps are needed:

  1. Open Joomla! admin page
  2. Login to Joomla!
  3. Open add article page
  4. Save and close

First we will create HttpClient and same instance I will use for every step:

HttpClientHandler httpClientHandler = new HttpClientHandler
{
    CookieContainer = new CookieContainer(),
    UseCookies = true,
    AllowAutoRedirect = true
};
HttpClient client = new HttpClient(httpClientHandler);

For every step we will need token

static string ExtractTokenName(string html)
{
    var regex = new Regex(@"""csrf\.token"":""(?<token>[a-f0-9]{32})""");
    var match = regex.Match(html);

    if (match.Success)
    {
        return match.Groups["token"].Value;
    }

    throw new Exception("CSRF-Token not found.");
}
  1. Open Joomla! admin page:
    async Task<string> OpenJoomlaAdminPage(HttpClient httpClient, string url) 
    {
        HttpResponseMessage getResponse = await httpClient.GetAsync(url);
        string html = await getResponse.Content.ReadAsStringAsync();
        return html;
    }
    
  2. Login to Joomla!:
    async Task<bool> LoginToJoomla(HttpClient httpClient, string url, string username, string password, string joomlaAdminPagehtml)
    {
        var tokenName = ExtractTokenName(joomlaAdminPagehtml);
        var tokenValue = "1";
        var formContent = new FormUrlEncodedContent([
            new KeyValuePair<string, string>("username", username),
            new KeyValuePair<string, string>("passwd", password),
            new KeyValuePair<string, string>("option", "com_login"),
            new KeyValuePair<string, string>("task", "login"),
            new KeyValuePair<string, string>(tokenName, tokenValue)
        ]);
        HttpResponseMessage postResponse = await httpClient.PostAsync(url, formContent);
        string postResult = await postResponse.Content.ReadAsStringAsync();
        return postResult.Contains("mod_quickicon") || postResult.Contains("cpanel");
    }
    
  3. Open add article page:
    async Task<string> OpenAddArticle(HttpClient httpClient, string addArticleUrl)
    {
        HttpResponseMessage createResponse = await httpClient.GetAsync(addArticleUrl);
        string createHtml = await createResponse.Content.ReadAsStringAsync();
        return ExtractTokenName(createHtml);
    }
    
  4. Save and close:
     
    async Task<bool> PostArticleToJoomla(HttpClient httpClient, string url, string articleToken, string title, string catid, string articletext)
    {
        var formData = new FormUrlEncodedContent(new[]
        {
            new KeyValuePair<string, string>("jform[title]", title),
            new KeyValuePair<string, string>("jform[catid]", catid),
            new KeyValuePair<string, string>("jform[language]", "*"), 
            new KeyValuePair<string, string>("jform[state]", "1"),
            new KeyValuePair<string, string>("jform[articletext]", articletext),
            new KeyValuePair<string, string>("task", "article.save"),
            new KeyValuePair<string, string>(articleToken, "1")
        });
    
        HttpResponseMessage postResponse = await httpClient.PostAsync(url, formData);
        string postResultHtml = await postResponse.Content.ReadAsStringAsync();
    
        return postResultHtml.Contains("Article saved.");
    }
    
Example download from here.