+ Start a Discussion
Lee SinLee Sin 

The format of value 'https://login.salesforce.com/services/oauth2/token/v30.0' is invalid.

Hi, I am using the Sample Code of Salesforce .NET toolkit. 
I am able to get the query result from a Console Application. However, after I moved the code to MVC application, it gives me this error.
"The format of value 'https://login.salesforce.com/services/oauth2/token/v30.0' is invalid."

Here's the code:
public static async Task<List<AdvisorMapInfo>> getAdvisorsAsync()
        {
            var auth = new AuthenticationClient();
            //Authenticate with Salesforce
            var url = IsSandboxUser.Equals("true", StringComparison.CurrentCultureIgnoreCase)
                ? "https://test.salesforce.com/services/oauth2/token"
                : "https://login.salesforce.com/services/oauth2/token";

            await auth.UsernamePasswordAsync(ConsumerKey, ConsumerSecret, Username, Password, url);           
            var client = new ForceClient(auth.InstanceUrl, auth.AccessToken, auth.ApiVersion);
            const string qry = "SELECT Name,Primary_Contact__c,Asset_Range_Lower__c,Asset_Range_Upper__c,BillingAddress FROM Account WHERE (Account_Type__c='Advisor' or Account_Type__c='provider')";
            var accts = new List<AdvisorMapInfo>();
            var results = await client.QueryAsync<AdvisorMapInfo>(qry);
            var totalSize = results.totalSize;
            accts.AddRange(results.records);
            var nextRecordsUrl = results.nextRecordsUrl;
            if (!String.IsNullOrEmpty(nextRecordsUrl))
            {
                while (true)
                {
                    var continuationResults = await client.QueryContinuationAsync<AdvisorMapInfo>(nextRecordsUrl);
                    totalSize = continuationResults.totalSize;
                    accts.AddRange(continuationResults.records);
                    if (string.IsNullOrEmpty(continuationResults.nextRecordsUrl)) break;
                    nextRecordsUrl = continuationResults.nextRecordsUrl;
                }
            }
            return accts;
            
        }


    }

public ActionResult AdvisorsMap()
        {
            List<AdvisorMapInfo> result = AdvisorsMapBL.getAdvisorsAsync().Result;
            return View(result);            
        }


 
ShashankShashank (Salesforce Developers) 
This page talks about updating the package for a similar error. Please have a look: http://paps-tech.blogspot.sg/2012/08/visual-studio-2012-systemformatexceptio.html