【问题标题】:Failed to connect Salesforce via c#无法通过 c# 连接 Salesforce
【发布时间】:2014-07-24 07:03:35
【问题描述】:

我正在尝试通过 C# 连接 Salesforce api。我已重置安全令牌并将其添加到我的密码中,然后我尝试连接。但是登录失败。我究竟做错了什么 ?如有任何帮助,我们将不胜感激。

登录功能:

        public void sForceLogin(String userName, String password)
        {
            try
            {
                currentLoginResult = sForce.login(userName, password);
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                Console.WriteLine("An exception has been catched:" + ex.Message);
            }
        }

主要:

        SForceTest sft = new SForceTest();
        sft.sForceLogin("example@example.com", "password+securitytoken");

【问题讨论】:

  • 你得到什么错误信息?如果您要连接到沙盒,则需要将 URL 更改为 test.Salesforce.com

标签: c# api salesforce


【解决方案1】:

您可以使用以下代码登录salesforce。

            using (SforceService service = new SforceService())
            {
                LoginResult loginResult = 
                service.login(username, String.Concat(password, securityToken));
                this.SessionID = loginResult.sessionId;
                this.ServerUrl = loginResult.serverUrl;
            }

Salesforce 登录 api 需要用户名、密码和安全令牌。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-17
    • 1970-01-01
    • 1970-01-01
    • 2018-02-05
    • 1970-01-01
    相关资源
    最近更新 更多