Access Storage Used information through API - Ideas - Salesforce Trailblazer Community

All Ideas

Idea Details

Post an Idea
This idea has been merged into another idea. To comment or vote on this idea, please visit Provide a webservice API call that tells end user the API usage.
This idea has been delivered and can no longer be voted or commented on. If you’d like to add to this conversation, please post a new idea.
0  Points voting closed
Delivered in Spring '15
Idea is generally available.

Salesforce provides the user  interface to check the Limit and Used of the Storage  from the Application Set Up -- Administration Setup -- Storage Usage .

 

But the information is not accessible through API.

 

If the Storage used information is available through the API then we can used the information as below:

 

 

          At the time of bulk data load from external API interface

                program  can check (if )the storage space available and make the decision

                                                to proceed with data load

 or (else)  Send an email to the Data Administrator.

 

· Flag

Latest Comment from Salesforce

  • IdeaExchange Moderator - 5 years ago

    Hi James here is what i heard back:
    This is possible today...not super great, but it works.

    Essentially, you have to build an apex class which does a callout to the REST API. You can then schedule that class to run in scheduled Apex. The big problem is that you have to pass a username and password as part of the login call to get a session:

    1. How to login and get a session - http://salesforce.stackexchange.com/questions/22704/sessionid-problem-in-schedule-batch-class
    2. Class to call the login:

    public class CurrentStorage {

    @Future(callout=true)
    public static void getStorage() {

    String sid = Login.login('<username>', '<password+api_token>');


    HttpRequest req = new HttpRequest();

    req.setMethod('GET');
    req.setEndpoint('
    https://na2.salesforce.com/services/data/v32.0/limits');
    req.setHeader('Authorization', 'OAuth '+ sid);

    Http http = new Http();

    HTTPResponse res = http.send(req);

    Map<String, Object> m = (Map<String,
    Object>)JSON.deserializeUntyped(res.getBody());
    Map<String, Object> dataStorage = (Map<String,
    Object>)m.get('DataStorageMB');

    System.debug('Current Storage: ' + dataStorage.get('Remaining'));
    return;
    }

    }


    You could then schedule #2
     
  • Upvotes
  • Downvotes

Ideas

Apps

from AppExchange

Questions

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



 

 

Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


 

Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.