• DalyProcessing
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

I am new to SalesForce and I am trying to retrieve the results of a query and keep getting a  (403) Forbidden Error.

I can login and retrieve a token without any problems.

The code to get  the HTTPWebRequest follows.

Any help would be appreciated.

 

Operating System: Windows 7 Ultimate 64 bit.

Dev Tools: Visual Studio 2010 Ultimate Service Pack 1

Network: Not a networked computer.

DSL Provider: ATT Uverse.

 

public void QuerySalesforce(TokenResponse token)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            // build LEAD query
            string query = ("SELECT FirstName, LastName FROM Lead WHERE Email = 'something@email.com'");
            string sfQuery = String.Format("{0}/services/data/v23.0/query?q={1}", token.instance_url, query);
            HttpWebRequest request = HttpWebRequest.Create(sfQuery) as HttpWebRequest;
            request.Headers.Add("Authorization", "OAuth " + token.access_token);
            request.ContentType = "application/json";
            request.Method = "GET";
            WebResponse webResponse = request.GetResponse();
            var sr = new System.IO.StreamReader(webResponse.GetResponseStream());
            string json = sr.ReadToEnd();
            var leads = js.Deserialize<sfdcLeadCollection<sfdcLeadForCollection>>(HttpUtility.UrlDecode(json));
        }

 

I am new to SalesForce and I am trying to retrieve the results of a query and keep getting a  (403) Forbidden Error.

I can login and retrieve a token without any problems.

The code to get  the HTTPWebRequest follows.

Any help would be appreciated.

 

Operating System: Windows 7 Ultimate 64 bit.

Dev Tools: Visual Studio 2010 Ultimate Service Pack 1

Network: Not a networked computer.

DSL Provider: ATT Uverse.

 

public void QuerySalesforce(TokenResponse token)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            // build LEAD query
            string query = ("SELECT FirstName, LastName FROM Lead WHERE Email = 'something@email.com'");
            string sfQuery = String.Format("{0}/services/data/v23.0/query?q={1}", token.instance_url, query);
            HttpWebRequest request = HttpWebRequest.Create(sfQuery) as HttpWebRequest;
            request.Headers.Add("Authorization", "OAuth " + token.access_token);
            request.ContentType = "application/json";
            request.Method = "GET";
            WebResponse webResponse = request.GetResponse();
            var sr = new System.IO.StreamReader(webResponse.GetResponseStream());
            string json = sr.ReadToEnd();
            var leads = js.Deserialize<sfdcLeadCollection<sfdcLeadForCollection>>(HttpUtility.UrlDecode(json));
        }

 

Hi,

 

We want to develop an application for the app exchange.

Our main application will be a stand alone service which will be scheduled to fetch Articles. That means our application will need to be able to access multiple customer accounts as easy as possible. What would be a good approach? 

When we obtain an OAuth security ID, I suppose we can only enter our own account details?