+ Start a Discussion
GYAN ANDRUSGYAN ANDRUS 

Hi Everyone,Please help me for http request and response,VERY URGENT Am not getting response

MY REQUEST
http://158.69.22.40:8001/addressValidator/AddressValidation/Address?username=mule&password=mule&address1=123 FIVE DOCK&address2=NSW 2046&address3=null

This is my http request,I need to give the Address,Subrub,post code,so i given dynamiccally

                   String serviceURL='http://158.69.22.39:8001/addressValidator/AddressValidation/Address?username=mule&password=mule&address1='+address1+'&address2='+address2+'&address3='+address3;
 
@Future(callout=true)  
   public static void callPostAdressAPI(Id contactId) {
    /*
        @contactId - Id of the contact to be sent for Verification API.
    */
        System.debug('ContactVerificationAPICaller.callPostAddressAPI started.');
        
        try {
            List<Contact> listContact = [
                select
                    Id,
                    Postal_Address__c,
                    Postal_Address_Country__c,
                    PostalDPID__c,
                    Postal_Address_Postcode__c,
                    Postal_Address_State__c,
                    Postal_Address_Suburb__c,
                    Postal_Address_Invalid__c 
                    from Contact
                    where id = :contactId];
                    
            if (listContact.size() == 1 ) {
                // Object of the action.
                Contact contactResult = listContact[0];
                
               String PostalDPID,Dpidvalue;   
            
               System.debug('contactResult.Postal_Address_Suburb__ccontactResult.Postal_Address_Suburb__c'+contactResult.Postal_Address_Suburb__c);
               System.debug('contactResult.Postal_Address_State__ccontactResult.Postal_Address_State__c'+contactResult.Postal_Address_State__c);       
               System.debug('contactResult.Postal_Address_Postcode__ccontactResult.Postal_Address_Postcode__c'+contactResult.Postal_Address_Postcode__c);    
               System.debug('contactResult.Postal_Address__ccontactResult.Postal_Address__c'+contactResult.Postal_Address__c); 
               
                   String address1=contactResult.Postal_Address__c;
                   
                   String address2=contactResult.Postal_Address_State__c+' '+contactResult.Postal_Address_Postcode__c;
                   String address3=null;
                   System.debug('Address 1 :'+address1);
                   System.debug('Address 2 :'+address2);
                   System.debug('Address 3 :'+address3);
                   String serviceURL='http://158.69.22.39:8001/addressValidator/AddressValidation/Address?username=mule&password=mule&address1='+address1+'&address2='+address2+'&address3='+address3;
                  
                   Http httpClient=new Http();
                   HttpRequest req = new HttpRequest();
                   req.setEndpoint(serviceURL);
                   req.setMethod('POST');
                   req.setHeader('Content-Type', 'multipart/form-data');
                   req.setBody(' ');
                   HttpResponse res = httpClient.send(req);
                   System.debug('Response : '+res.getBody());
                    String soapResponse = res.getBody();
                    DPIDParser cls=new DPIDParser();
                    DPIDParser parsedResponse =cls.parse(soapResponse); 
                  
                    if(parsedResponse != null) {
                        PostalDPID = parsedResponse.DPID;
                        contactResult.PostalDPID__c = PostalDPID;
                    }
                  
                    if(PostalDPID == '' || PostalDPID == ' ' ) {
                        contactResult.Postal_Address_Invalid__c= true;
                    } else {
                        contactResult.Postal_Address_Invalid__c= false;
                    }
                 
            
              update contactResult;
                
            } 
        }catch (Exception ex){
            System.debug(ex);
        }
        System.debug('ContactVerificationAPICaller.callPostAdressAPI finished.');
    }

 
viruSviruS
What you are getting at System.debug('Response : '+res.getBody());   line #49.
GYAN ANDRUSGYAN ANDRUS
i am getting response


USER_DEBUG|[173]|DEBUG|Response : {"Postcode":"2251","State":"NSW","Address2":"NSW2251","Address1":"4THEGLADE","DPID":"00000000","Suburb":""}
The DPID Should be some value
viruSviruS
Are you providing a valid address .. Like State, PostCode.. if not please try using valid / real address. If it is valid address then connect with your Address validator service providor 
GYAN ANDRUSGYAN ANDRUS
yes,given valid address only,I need to know,my request is coreect?
viruSviruS
Request is looking good. debug at sevice provider side what other parameter it expecing for valid DPID
GYAN ANDRUSGYAN ANDRUS

USER_DEBUG|[173]|DEBUG|Response : {"Postcode":"2251","State":"NSW","Address2":"NSW2251","Address1":"4THEGLADE","DPID":"00000000","Suburb":""}