首页 > 解决方案 > 在 C# 中调用 post api 方法,而您必须设置代理服务器和端口

问题描述

我必须从服务器调用 post 方法,这迫使我使用特殊的代理服务器和端口。我已经通过下面的代码在 c# 中调用了 post 方法,但是现在,我找不到任何设置特殊代理的地方。请帮助我,非常感谢

public HttpResponseMessage Authenticate(AuthenticateDTO entity)
        {
            using (var client = new HttpClient())
            {

                client.BaseAddress = new Uri("http://restapi.x.com/SuperClient/V1/APIAUTHENTICATE");

                var response = client.PostAsJsonAsync("SuperClient/V1/APIAUTHENTICATE", entity).Result;
                if (response.IsSuccessStatusCode)
                {
                    Console.Write("Success");
                }
                else
                    Console.Write("Error");
            }
            return null;
        }

标签: c#apirestful-url

解决方案


推荐阅读