.net http formdata way request

There are ways to interface accepts formdata mass participation

I tried everything. In the postman can call succeeds, the code does not work in all kinds,

Finally Baidu to https://www.cnblogs.com/anech/p/9880036.html  measured feasible

var multipartFormDataContent = new MultipartFormDataContent();
            multipartFormDataContent.Add(new StringContent("admin"), "UserName");
            multipartFormDataContent.Add(new StringContent("123456"), "Password");
            var client = _clientFactory.CreateClient();
            var response = await client.PostAsync("http://localhost", multipartFormDataContent);
            if (response.IsSuccessStatusCode)
            {
                //do
            }

 

Guess you like

Origin www.cnblogs.com/landonys/p/11984676.html