• Shubham Gupta 93
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
hello guys i basically need to get DataStorageMB from limits api

in lightning when i tried to ran below code 
 
​ Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://rohakela-dev-ed.lightning.force.com/services/data/v37.0/limits');
        req.setHeader(Authorization, 'Bearer '+UserInfo.getSessionId());
        req.setMethod(GET);
        HttpResponse res = http.send(req);
        jsonOutput = res.getBody();
        String loc = res.getHeader('Location');
        system.debug(loc);
        system.debug('outputis '+jsonOutput);
        Map<String, Object> m = (Map<String, Object>) JSON.deserializeUntyped(jsonOutput);

i got 302 error saying resource moved so i added 
String loc = res.getHeader('Location');        
system.debug(loc);

to see which is the new URL its pointing to and it was 
https://rohakela-dev-ed.my.salesforce.com/services/data/v37.0/limits

so i added above url as end point and also added to remote setting.

but doing so as below 
Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://rohakela-dev-ed.my.salesforce.com/services/data/v37.0/limits');
        req.setHeader(Authorization, 'Bearer '+UserInfo.getSessionId());
        req.setMethod(GET);
        HttpResponse res = http.send(req);
        jsonOutput = res.getBody();
        String loc = res.getHeader('Location');
        system.debug(loc);
        system.debug('outputis '+jsonOutput);
        Map<String, Object> m = (Map<String, Object>) JSON.deserializeUntyped(jsonOutput);
but now its showing below error

System.HttpResponse[Status=Unauthorized, StatusCode=401]"|0x14b7be94

outputis [{"message":"This session is not valid for use with the REST API","errorCode":"INVALID_SESSION_ID"}]


 
hello guys i basically need to get DataStorageMB from limits api

in lightning when i tried to ran below code 
 
​ Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://rohakela-dev-ed.lightning.force.com/services/data/v37.0/limits');
        req.setHeader(Authorization, 'Bearer '+UserInfo.getSessionId());
        req.setMethod(GET);
        HttpResponse res = http.send(req);
        jsonOutput = res.getBody();
        String loc = res.getHeader('Location');
        system.debug(loc);
        system.debug('outputis '+jsonOutput);
        Map<String, Object> m = (Map<String, Object>) JSON.deserializeUntyped(jsonOutput);

i got 302 error saying resource moved so i added 
String loc = res.getHeader('Location');        
system.debug(loc);

to see which is the new URL its pointing to and it was 
https://rohakela-dev-ed.my.salesforce.com/services/data/v37.0/limits

so i added above url as end point and also added to remote setting.

but doing so as below 
Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://rohakela-dev-ed.my.salesforce.com/services/data/v37.0/limits');
        req.setHeader(Authorization, 'Bearer '+UserInfo.getSessionId());
        req.setMethod(GET);
        HttpResponse res = http.send(req);
        jsonOutput = res.getBody();
        String loc = res.getHeader('Location');
        system.debug(loc);
        system.debug('outputis '+jsonOutput);
        Map<String, Object> m = (Map<String, Object>) JSON.deserializeUntyped(jsonOutput);
but now its showing below error

System.HttpResponse[Status=Unauthorized, StatusCode=401]"|0x14b7be94

outputis [{"message":"This session is not valid for use with the REST API","errorCode":"INVALID_SESSION_ID"}]


 
Challenge - Create a form to enter new items and display the list of items entered. To make our camping list look more appealing, change the campingHeader component to use the SLDS. Similar to the unit, style the Camping List H1 inside the slds-page-header. Modify the campingList component to contain an input form and an iteration of campingListItem components for displaying the items entered.
The component requires an attribute named items with the type of an array of camping item custom objects.
The component requires an attribute named newItem of type Camping_Item__c with default quantity and price values of 0.
The component displays the Name, Quantity, Price, and Packed form fields with the appropriate input component types and values from the newItem attribute.
The JavaScript controller checks to ensure that the Name, Quantity and Price values submitted are not null.
If the form is valid, the JavaScript controller pushes the newItem onto the array of existing items, triggers the notification that the items value provider has changed, and resets the newItem value provider with a blank sObjectType of Camping_Item__c.


My answer - 
<aura:component >
<aura:attribute name="items" type="Camping_Item__c[]"/>
<aura:attribute name="newitem" type="Camping_Item__c[]"  default="{ 'sobjectType': 'Camping_Item__c',
                   'Quantity__c'=0, 'Price__c'=0}"/>
 <p>Name:
        <ui:inputText value="{!v.newitem.name}"/>
    </p>    
  <p>Packed:
        <ui:inputCheckbox value="{!v.newitem.Packed__c}"/>
     
    </p>    
  <p>Price:
        <ui:inputCurrency value="{!v.newitem.Price__c}"/>
    </p>
    <p>Quantity:
        <ui:inputNumber value="{!v.newitem.Quantity__c}"/>
    </p>
</aura:component>


Error -

Challenge Not yet complete... here's what's wrong: 
The campingList component isn't iterating the array of 'items' and creating 'campingListItem' components.

Please share the correct solution.