Good afternoon, I have been doing a small development in C #, for the request in HTTP POST.
I have the following problem, when trying in c # the following have not worked for me
using RestSharp;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
namespace App_Llamadas_API
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[Obsolete]
private void button1_Click(object sender, EventArgs e)
{
//URL:
var client = new RestClient("Hidden URL");
var request = new RestRequest("/", Method.POST);
//Headers:
request.AddHeader("X-Authorization", "Hidden Token");
request.AddHeader("Content-Type", "application/json");
//Body json:
request.AddParameter(
"application/json",
"{ \"taskRelativePath\": \"My Tasks\\VPN.atmx\", \"botRunners\": [{ \"client\": \"DESKTOP -Hidden name\", \"user\": \"botrunner03\"}], \"runWithRDP\": \"true\" }", // <- your JSON string
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var content = response.Content;
txtResponse.Text = content;
}
}
}
reply: {"code":"json.deserialization.exception","details":null,"message":"Invalid request parameters"}