I'm trying to get a basic login feature working using RestSharp. I have the login user and password as text that I need to convert somehow since the server accepts requests as multipart/form-data and my initial attempt was this:
RestRequest request = new RestRequest(resource, Method.POST);
request.AddParameter("login", config.Login, ParameterType.RequestBody);
request.AddParameter("pass", config.Password, ParameterType.RequestBody);
Only to find out I cannot add two params for request body, where it discards all but the first. So my next attempt was to build the requestBody:
MultipartFormDataContent formData = new MultipartFormDataContent();
formData.Add(new StringContent(config.Login), "login");
formData.Add(new StringContent(config.Password), "pass");
request.AddBody(formData);
This also didnt work and just returned the closed element </MultipartFormDataContent>
Last I tried to just pass them as post params rather than the body, which it seems to have just ignored considering it expects a form I guess:
request.AddParameter("login", JsonConvert.SerializeObject(config.Login), ParameterType.GetOrPost);
request.AddParameter("pass", JsonConvert.SerializeObject(config.Password), ParameterType.GetOrPost);
I'm looking for any tips on how I can somehow convert and send this text as valid form-data. It looks easier to do with HTTPWebRequest rather than RestSharp but it's bothering me that I'm sure it's possible.
Thanks so much!