function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rishi jaykar 1rishi jaykar 1 

what is "Authorization: Bearer ***token*** "X-PrettyPrint:1" in curl https://instance.salesforce.com/services/data/v37.0/limits/ -H "Authorization: Bearer ***token*** "X-PrettyPrint:1"

how to use this curl in my class and return JSON result store in array or list in my controller class? 
Prafull G.Prafull G.
If you want to use this from controller class then you need to make use of Http classes. 

All Salesforce resources are protected and in order to use those we need to authenticate first and then use access_token. Please refer below link for more details

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_authentication.htm
LBKLBK
Bearer is a type of OAuth token returned by your Authorization call.

This is how you have to consume it in a Callout service.
 
public class clsHTTPCalloutService {
	//If you dont have an input JSON, you can skip the argument 1
    public static String Callout(String sInputJson, String sToken) {
        String returnValue = '';
        try {
            Http http = new Http();
            HttpRequest request = new HttpRequest();
            request.setEndpoint('https://instance.salesforce.com/services/data/v37.0/limits/');  //Your URI
            request.setMethod('POST');
            request.setHeader('Authorization', 'Bearer ' + sToken);
			request.setHeader("X-PrettyPrint:1");
			
			//if the request and response for your REST call is JSON, use the code below.
            request.setHeader('Content-Type', 'application/json'); 
            request.setHeader('accept', 'application/json');
            request.setBody(sInputJson);
            
			HttpResponse response = http.send(request);

            // Parse the JSON response          
            if (response.getStatusCode() != 200) { //Make sure about the Status code with Dev team
                System.debug('The status code returned was not expected: ' +
                             response.getStatusCode() + ' ' + response.getStatus());
                returnValue = 'ERROR';
            } 
            else {
                returnValue = response.getBody();
            }
            
            return returnValue;
        } 
        catch(System.CalloutException e) {
            return null;
        }
    }
}
If you do not have JSON input or output, you can skip the related code pieces.

Let me know if this helps.
 
rishi jaykar 1rishi jaykar 1
firstly i want to get the result from  https://instance.salesforce.com/services/data/v37.0/limits/ -H "Authorization: Bearer ***token*** "X-PrettyPrint:1"  but the problem with this curl what is "Authorization: Bearer ***token*** "X-PrettyPrint:1"
Like: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_limits.htm
(go through link) this format 
rishi jaykar 1rishi jaykar 1
Hii @LBK
its really helpful but the problem is there, what is Authorization ,Bearer ,sToken​ and X-PrettyPrint:1​ in these 2 line request.setHeader('Authorization', 'Bearer ' + sToken);        request.setHeader("X-PrettyPrint:1");
LBKLBK
Hi,

You need to read some materials on HTTPRequest and Response classes. Try the URL below.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_httprequest.htm

And, various headers available in Request class.
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields

This is a good place to start. There are more information available on OAuth2.0, and various types of responses you get from that.

Google is your friend in need.