Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am running the same code in two different environments and I am getting different results. I have the following code hitting the REST API exposed on StackExchange:

Http httpQuestions = new Http();
HttpRequest requestQuestions = new HttpRequest();
requestQuestions.setEndpoint('http://api.stackexchange.com/2.2/users/605/questions?order=desc&sort=activity&site=salesforce');
requestQuestions.setMethod('GET');
requestQuestions.setHeader('Content-Type', 'application/json');
HTTPResponse responseQuestions = httpQuestions.send(requestQuestions);
System.debug('Get Questions: ' + responseQuestions.getBody());

Basically, what this should do is call out to the API and return all of the questions I have asked (my user Id is 605). When I run this code in Execute Anonymous in Winter '14, the request returns a 200 response and I get the following from the debug statement (ran it through JSONPrettyPrint for readability):

15:56:49:374 USER_DEBUG [7]|DEBUG|Get Questions: {
  "items": [
    {
      "tags": [
        "pre-release"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 224,
      "accepted_answer_id": 25486,
      "answer_count": 2,
      "score": 4,
      "last_activity_date": 1391032089,
      "creation_date": 1390247152,
      "question_id": 24668,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/24668\/writing-apex-in-spring-14-prerelease-org",
      "title": "Writing Apex in Spring '14 Prerelease Org"
    },
    {
      "tags": [
        "soql",
        "lookup"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 110,
      "accepted_answer_id": 25011,
      "answer_count": 1,
      "score": 4,
      "last_activity_date": 1390542679,
      "creation_date": 1390521475,
      "question_id": 25001,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/25001\/nested-soql-query-on-object-w-lookup-to-same-object",
      "title": "Nested SOQL Query On Object w\/ Lookup To Same Object"
    },
    {
      "tags": [
        "salesforce1-app"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 196,
      "accepted_answer_id": 23865,
      "answer_count": 2,
      "score": 4,
      "last_activity_date": 1389706625,
      "creation_date": 1389274614,
      "question_id": 23864,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/23864\/set-standard-objects-as-menu-item-in-salesforce1",
      "title": "Set Standard Objects as Menu Item in Salesforce1?"
    },
    {
      "tags": [
        "lookup",
        "page-layout",
        "create-records"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 71,
      "accepted_answer_id": 22462,
      "answer_count": 1,
      "score": 6,
      "last_activity_date": 1387298696,
      "creation_date": 1387298188,
      "last_edit_date": 1387298510,
      "question_id": 22460,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/22460\/modify-new-object-layout-through-lookup",
      "title": "Modify "New" Object Layout through Lookup"
    },
    {
      "tags": [
        "soql",
        "sosl"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 5567,
      "accepted_answer_id": 9029,
      "answer_count": 2,
      "score": 16,
      "last_activity_date": 1385919473,
      "creation_date": 1362021485,
      "question_id": 9028,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/9028\/soql-vs-sosl-which-one-to-use-and-when",
      "title": "SOQL vs SOSL - Which one to use and when?"
    },
    {
      "tags": [
        "visualforce"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 3323,
      "protected_date": 1382362080,
      "accepted_answer_id": 8140,
      "answer_count": 1,
      "score": 38,
      "last_activity_date": 1382351724,
      "creation_date": 1360161554,
      "last_edit_date": 1360249961,
      "question_id": 8139,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/8139\/difference-between-the-multiple-messaging-options-in-visualforce",
      "title": "Difference between the multiple messaging options in Visualforce?"
    },
    {
      "tags": [
        "leads",
        "lead-conversion"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 213,
      "accepted_answer_id": 17800,
      "answer_count": 1,
      "score": 6,
      "last_activity_date": 1381175720,
      "creation_date": 1381173961,
      "question_id": 17799,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/17799\/multiple-contacts-per-lead-possible",
      "title": "Multiple Contacts Per Lead - Possible?"
    },
    {
      "tags": [
        "ide"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 1702,
      "protected_date": 1377220053,
      "accepted_answer_id": 15659,
      "answer_count": 2,
      "score": 61,
      "last_activity_date": 1379438764,
      "creation_date": 1376944562,
      "last_edit_date": 1376949857,
      "question_id": 15654,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/15654\/force-com-ide-still-officially-supported",
      "title": "Force.com IDE - Still Officially Supported?"
    },
    {
      "tags": [
        "apex",
        "unit-test",
        "batch",
        "api-27"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 1624,
      "accepted_answer_id": 8978,
      "answer_count": 1,
      "score": 7,
      "last_activity_date": 1368082166,
      "creation_date": 1361912702,
      "last_edit_date": 1365153475,
      "question_id": 8959,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/8959\/no-mass-mail-permission-error-from-unit-test-on-singlemailmessage",
      "title": "NO_MASS_MAIL_PERMISSION Error from Unit Test on SingleMailMessage"
    },
    {
      "tags": [
        "developer-console",
        "api-27"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 1144,
      "protected_date": 1362776429,
      "accepted_answer_id": 9191,
      "answer_count": 1,
      "score": 16,
      "last_activity_date": 1365700479,
      "creation_date": 1362156576,
      "last_edit_date": 1362166843,
      "question_id": 9131,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/9131\/developer-console-issues-in-chrome-spring-13",
      "title": "Developer Console - Issues in Chrome Spring '13?"
    },
    {
      "tags": [
        "deployment",
        "migration-tool"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 418,
      "accepted_answer_id": 10187,
      "answer_count": 3,
      "score": 11,
      "last_activity_date": 1364654401,
      "creation_date": 1364565408,
      "last_edit_date": 1364565843,
      "question_id": 10170,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/10170\/deploy-to-production-cancel-deploy-after-test-failure",
      "title": "Deploy to Production - Cancel Deploy After Test Failure"
    },
    {
      "tags": [
        "apex",
        "approval-process"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 574,
      "accepted_answer_id": 8152,
      "answer_count": 2,
      "score": 3,
      "last_activity_date": 1363279254,
      "creation_date": 1360170102,
      "last_edit_date": 1360174891,
      "question_id": 8150,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/8150\/programmatically-stopping-approval-process-email",
      "title": "Programmatically Stopping Approval Process Email"
    },
    {
      "tags": [
        "ide"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 122,
      "answer_count": 1,
      "score": 1,
      "last_activity_date": 1362633144,
      "creation_date": 1362585799,
      "question_id": 9278,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/9278\/force-com-ide-easy-push-of-single-file-through-single-key-combo",
      "title": "Force.com IDE - Easy Push of Single File Through Single Key Combo?"
    },
    {
      "tags": [
        "apex",
        "unit-test",
        "developer-console"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 365,
      "accepted_answer_id": 9151,
      "answer_count": 2,
      "score": 6,
      "last_activity_date": 1362265094,
      "creation_date": 1362162793,
      "question_id": 9136,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/9136\/force-a-unit-test-to-run-immediately-inside-salesforce-web-ui",
      "title": "Force a Unit Test to run immediately inside Salesforce Web UI?"
    },
    {
      "tags": [
        "deployment",
        "migration-tool",
        "package"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 535,
      "accepted_answer_id": 9057,
      "answer_count": 1,
      "score": 6,
      "last_activity_date": 1362061078,
      "creation_date": 1362060569,
      "question_id": 9056,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/9056\/sfretrieve-gets-a-file-but-sfdeploy-cant-find-it-for-the-deploy",
      "title": "sf:retrieve gets a file, but sf:deploy can't find it for the deploy?"
    },
    {
      "tags": [
        "metadata-api",
        "migration-tool"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 708,
      "accepted_answer_id": 8791,
      "answer_count": 1,
      "score": 5,
      "last_activity_date": 1361459880,
      "creation_date": 1361457257,
      "question_id": 8783,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/8783\/full-list-of-all-accessible-types-through-metadata-api",
      "title": "Full List of All Accessible Types Through Metadata Api"
    },
    {
      "tags": [
        "site.com"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 353,
      "bounty_amount": 50,
      "accepted_answer_id": 8022,
      "answer_count": 1,
      "score": 7,
      "last_activity_date": 1359983695,
      "creation_date": 1358274012,
      "last_edit_date": 1359745295,
      "question_id": 7264,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/7264\/site-com-incorrectly-escaping-image-urls",
      "title": "Site.com - Incorrectly Escaping Image URLs"
    },
    {
      "tags": [
        "deployment",
        "migration-tool",
        "migration"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 190,
      "accepted_answer_id": 7982,
      "answer_count": 1,
      "score": 3,
      "last_activity_date": 1359756293,
      "creation_date": 1359745845,
      "question_id": 7971,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/7971\/ant-migration-tool-order-of-package-xml-file-matter",
      "title": "Ant Migration Tool - Order of Package.xml File Matter?"
    },
    {
      "tags": [
        "search"
      ],
      "owner": {
        "reputation": 9106,
        "user_id": 605,
        "user_type": "registered",
        "accept_rate": 95,
        "profile_image": "http:\/\/i.stack.imgur.com\/2xQqK.png?s=128&g=1",
        "display_name": "Jesse Altman",
        "link": "http:\/\/salesforce.stackexchange.com\/users\/605\/jesse-altman"
      },
      "is_answered": true,
      "view_count": 603,
      "accepted_answer_id": 7641,
      "answer_count": 1,
      "score": 1,
      "last_activity_date": 1359042717,
      "creation_date": 1358523859,
      "question_id": 7417,
      "link": "http:\/\/salesforce.stackexchange.com\/questions\/7417\/customizing-global-search",
      "title": "Customizing Global Search"
    }
  ],
  "has_more": false,
  "quota_max": 300,
  "quota_remaining": 299
}

When I run that same exact code in Spring '14, I get a 403 error with the following from the debug statement:

19:06:24.142 (142925130)|USER_DEBUG|[12]|DEBUG|Get Questions: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to retrieve the URL:
<A HREF="http://api.stackexchange.com/2.2/users/605/questions?">http://api.stackexchange.com/2.2/users/605/questions?</A>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Access Denied.
</STRONG>
<P>
Access control configuration prevents your request from
being allowed at this time.  Please contact your service provider if
you feel this is incorrect.
</UL>
<P>Your cache administrator is <A HREF="mailto:root">root</A>. 


<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated Wed, 09 Apr 2014 23:06:24 GMT by proxy-sfm.net.salesforce.com (squid)
</ADDRESS>
</BODY></HTML>

In both scenarios, I have the Remote Site Details set up as:

Remote Site Details

The interesting thing about the Spring '14 scenario is that the HTML that gets returned from the 403 error indicates that http://api.stackexchange.com/2.2/users/605/questions? is the URL that is getting called. It appears to be dropping the URL query parameters when making the call out. Has anyone seen anything else like this? Is it possible I am missing something really simple? I haven't done a ton with callouts in Apex to be honest, so I am not sure if I am just doing something wrong or if I found a bug.

share|improve this question
    
might be an internal issue, what Spring '14 instance are you on? –  Ryan Guest Apr 9 at 23:19
    
1  
I just tested on a Sandbox (CS14) on Spring 14 and it worked fine there. –  Daniel Hoechst Apr 9 at 23:22
    
If it matters, my dev org on Winter '14 is on na15.salesforce.com –  Jesse Altman Apr 9 at 23:22
1  
pre-rel doesn't have the same internet access as production, you are being blocked by the pre-rel outbound proxy –  superfell Apr 9 at 23:45
show 6 more comments

1 Answer 1

up vote 8 down vote accepted

You can't call out from a pre-release org, since the security rules are different from our production/developer environments.

share|improve this answer
    
Ah - I just read the comments and saw that @superfell had already given the same answer... Should I delete my answer and let Simon earn the points? –  metadaddy Apr 10 at 0:05
4  
no need for that. –  superfell Apr 10 at 0:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.