Dear Dojo,
I'm trying to implement my first automation script with terrible results. I am writing code for an automation script that simply executes an HTTP POST through an api url, can anyone help me please? Thanks.
Hi Marco,
Could you please clarify what you mean with "terrible results"? What exactly have you tried, and which specific problems are you encountering?
One way to execute the HTTP POST request is by using the HttpClient class.
First of all, a reference to the "System.Net.Http" assembly needs to be added to your C# project. This is explained here: https://learn.microsoft.com/en-us/shows/csharp-fundamentals-for-absolute-beginners/creating-and-adding-references-to-assemblies.
Next, add the following using directive at the top of your C# file:
using System.Net.Http;
Here’s a basic example of how to use HttpClient to send a POST request:
using (var httpClient = new HttpClient())
{
var jsonContent = "...";
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
httpClient.PostAsync(@"http:\\www.example.com", content);
}
Hopefully this helps you further. Let me know if you have further questions or need additional guidance.
Hi Tom. The truth is that I don’t understand how the automation script works. I have seen many tutorials but I still don’t understand. I need a script that will make an HTTP POST request to an URL with parameters. This script will be used in a low code application after a button is clicked. Thanks in advance
Would it be an option to use engineering services to support you, so you can get on call and to get personal training or to let the person develop the script/LCA?