I have already added my url to the remote site list however I still receive an error.

The endpoint here is a dev sandbox I just created for testing purposes. endpoint: https://um1.lightning.force.com

public static void putCallout(){
    List<Case> cases = [select id, subject, status, Origin from case limit 5];
    String str = JSON.serialize(cases);
    System.debug('json str: ' + str);

    Http http = new Http();
    HttpRequest request = new HttpRequest();
    request.setEndpoint('https://um1.lightning.force.com/services/apexrest/Cases/*'); // webserivce callout
    request.setHeader('Content-Type', 'application/json;charset=UTF-8');
    HttpResponse response = http.send(request);

    while (response.getStatusCode() == 302) {
        response = new Http().send(request);
    if(response.getStatusCode() == 200){
        System.debug('Response str: ' + response.getBody());
        System.debug('Response is not what we expected: ' + response.getStatusCode());

Any ideas why I still get the following error:

 System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://um1.salesforce.com/services/apexrest/Cases/*

Because you've got a different address here:


to here:


It's giving a 302 to the first request, you have an automated rerequest, but you haven't added the redirect url to your allowed settings.

Add - 'https://um1.salesforce.com/' url to allowed remote site.

| improve this answer | |
  • Thanks. I get a 401 error after adding named credentials and Authentication Settings for External Systems. Any ideas? – M guy Feb 4 at 10:52
  • If it is just for testing purposes, you can add the rest resource to a sites page then hit up the resource through a site url without having to auth in. developer.salesforce.com/blogs/developer-relations/2012/02/… – eaeaoo Feb 4 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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