Submit Form Data using RestSharp

  • Thread starter Thread starter JL11111
  • Start date Start date
J

JL11111

Guest
I am trying to emulate the following curl command in c# using RestSharp.

curl URL -F "login=samplelogin" -F "key=password"

I am using the following c# code to format the request:

// Configure Request

RestRequest request = new RestRequest(resource, Method.POST);

request.AddParameter("login", context.Control.CourtLogin, ParameterType.RequestBody);
request.AddParameter("Key", context.Control.CourtPassword, ParameterType.RequestBody);


request.AddHeader("Content-Type", "multipart/form-data");


The client endpoint just returns login failure. When I read the documentation for AddParameter on the RestRequest class. It states you can only have key value pair with parameter type = RequestBody.

Does anyone have any ideas on how to get multiple form data key value pairs in a RestSharp client request? Or how to duplicate the -F curl option using RestSharp?

Thanks in advance!

Continue reading...
 
Back
Top