I created WebAPI service. I have controller in the service, and it looks like:
public class MyController : ApiController
{
[HttpPost]
public ResponceTools.APIResponce UserLoggedIn(UserArgs args)
{
//doing something
}
}
where
public class UserArgs
{
public string UserID { get; set; }
}
I can send request to the the method UserLoggedIn and give adequate response using curl :
curl --data "UserID=7822f2b9-44f1-4e30-a9da-d26e277fa0ac" http://localhost:8081/UserLoggedIn"
Now I'm writing .net Core Web App, and I want to use this service.
string requestStr = WebAPIURL + "/UserLoggedIn";
var content = new StringContent("UserID=" + userID.ToString(),
System.Text.Encoding.Unicode,
"application/xml");
var task = client.PostAsync(requestStr, content);
var str = await task.Result.Content.ReadAsStringAsync();
but the method args value is null.
What am I doing wrong?
P.S. I tried to activate XmlSerializer in my WebApi application in "Register" method. It does not help.
config.Formatters.XmlFormatter.UseXmlSerializer = true;
Thank you for any help.