There are 500 pieces of data I got from excel in Listbox1. How can I post them all with Restsharp. In one sentence I have to put commas in the code in order for the item in listbox1. Example: ("hes" + "code"), ("hes" + "code"), ("hes" + "code"), ("hes" + "code"), ("hes" + "code" ), ....
Code :
public string hes; public string code;
public AnaForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var client = new RestClient("url);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic idpw");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "Cookie_1=value; mycode");
for (int i = 0; i < listBox1.Items.Count; i++)
{
if ((i + 1) <= listBox1.Items.Count )
{
hes = "hes_code";
code += listBox1.Items[i];
request.AddParameter("application/json", "[{\"" + hes + "\": \"" + code + "\"}]", ParameterType.RequestBody);
}
}
IRestResponse response = client.Execute(request);
textBox1.Text = response.Content;