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
dudu-avdudu-av 

Question regarding http request

Hi all,

I wanted to know if there any way to see the http request , for example  basic http request   , and i want  to see the actual request that is sent from salesforce server 

 

public void basicAuthCallout(){
     HttpRequest req = new HttpRequest();
     req.setEndpoint('http://www.yahoo.com');
     req.setMethod('GET');
     
     // Specify the required user name and password to access the endpoint  
    
     // As well as the header and header information  
    
 
     String username = 'myname';
     String password = 'mypwd';
  
     Blob headerValue = Blob.valueOf(username + ':' + password);
     String authorizationHeader = 'BASIC ' +
     EncodingUtil.base64Encode(headerValue);
     req.setHeader('Authorization', authorizationHeader);
   
     // Create a new http object to send the request object  
    
     // A response object is generated as a result of the request    
    
  
     Http http = new Http();
     HTTPResponse res = http.send(req);
     System.debug(res.getBody());
   }
dudu-avdudu-av

Thanks !

 

I understand that it support only POSt request , do you know if there is a difference between post to put 

because my setmethods=PUT , ?  

 

Another question , I noticed that salesforce add headers to my request is there a way to cancel those headers 

Afzal MohammadAfzal Mohammad

Am not aware of any such difference, but am curious to know how it effects your implementation? Are you unable to send a http request, when you use PUT?

 

Afzal

dudu-avdudu-av

When I am using the put  I can't use  the   http://www.postbin.org. (because it work only with post  )

 

Another question , I noticed that salesforce add headers to my request is there a way to cancel those headers