Tuesday, 28 October 2014

HTTP Callouts to Shopify from Salesforce


       String jSONStr=jGen.getAsString();
          string url='https://test.myshopify.com/admin/';
         string EndPointUrl=url+'orders.json';
          HttpRequest req = new HttpRequest();
         req.setEndpoint(EndPointUrl);
         req.setMethod('POST');
         String username =
APIKEY;
         String password =passwordfromApps Tab;
       
         Blob headerValue = Blob.valueOf(username + ':' + password);
         String authorizationHeader = 'Basic ' +
         EncodingUtil.base64Encode(headerValue);
         req.setHeader('Authorization', authorizationHeader);
         req.setHeader('content-type','application/json');
         req.setBody(jSONStr);
         Http http = new Http();
         HTTPResponse res = http.send(req);
         System.debug('*****Response*****'+res.getBody());

2 comments: