Friday, 27 May 2016

How to make api calls for encoded url from apex

 HttpRequest req = new HttpRequest();
                req.setEndpoint(AuthUrl);
                req.setMethod('POST');
                req.setHeader('Accept', 'application/json');
                req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
      req.setBody('api_key=' + EncodingUtil.urlEncode(AuthApi, 'UTF-8')
                + '&'
                + 'email=' + EncodingUtil.urlEncode(AuthEmail, 'UTF-8')
                );
     
        HttpResponse res = new Http().send(req);
  system.debug('***endpoint ***'+req.getEndpoint() );
        system.debug('***statuscode ***'+res.getstatuscode() );
          system.debug('***getBody ***'+res.getBody() );

No comments:

Post a Comment