String filter = 'OrderNumber eq \'1000035\' and SoldtoCustomer eq \'10045005\'';
    String Username = user;
    String Password = pass;
    String expand = 'EvLineDetailsSet';
    String format ='json';
    String reqBody ='$filter=' +filter;
    reqBody = reqBody + '&$expand=' + expand;               
    reqBody = reqBody + '&$format=' + format;  
    system.debug('********request Body*******'+reqBody);
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        String endpoint =  'https://onehdwebpre.hunterdouglas.com/CUSTOMERORDERDETAILS/EvHeaderDetailsSet';

        Blob headerValue = Blob.valueOf(Username + ':' + Password);

        String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        request.setHeader('Authorization', authorizationHeader);

        HttpResponse response = http.send(request);
        system.debug('*******response*******' +response.getBody());
    catch(Exception e){
        system.debug('Inside catch'+e.getMessage());

I am using the above code but in response getting csrf token not valid while the URL is working on postman. Can anyone tell what is wrong in the code?

  • I would suggest to remove your username and password from the post. – gorav Jul 26 '19 at 10:53
  • What error code you are getting in response? – वरुण Jul 28 '19 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.