I am trying to send parameters & file in Request Body with Origin Request Header C# Console / Asp.Net (Web Form) Web Application. I have looked around many examples but I didn't get proper solutions.
I've tried with the following code which is almost working. The only issue with couldn't get any solution to send the file in Request Body.
public class requestObj
{
public string langType { get; set; }
}
protected void CreateUser_Click(object sender, EventArgs e)
{
try
{
var requestObj = new requestObj
{
langType = "aaa"
};
var client = new RestSharp.RestClient(url);
client.Timeout = -1;
var request = new RestSharp.RestRequest(RestSharp.Method.POST);
request.AddHeader("Origin", "http://localhost:8080");
request.AddJsonBody(requestObj);
var response = client.Execute(request);
}
catch (Exception ex)
{
throw ex;
}
}
Thanks,