I am trying to post request to contactability API. Documentation can be found at http://dev.contactability.com/ping_post/v1/docs/contactability-api.html
There is some sample xml that can be used to make request. So, I have tried an example but the api response " ERROR Bad Request XML validation failed. Please check the XML and try again. 0.00 " Which means My xml is not valid according to their api requirments. Can anyone help me to save my day please?
<?php $file = ' <InsuranceRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <AffiliateInfo> <PartnerID>3</PartnerID> <Token>G15QncRptYzJftqUauVyodKvsoZWxArrhiukhbkjr</Token> <TrackingCampaign>MyCampaign</TrackingCampaign> <LeadSourceID>InHouse</LeadSourceID> <ProductionEnvironment>true</ProductionEnvironment> </AffiliateInfo> <DistributionDirectives> <Cap>5</Cap> <DistributionCount>3</DistributionCount> <Excludes> <Exclude> <CarrierName>Independent</CarrierName> <LicenseNumber>4491903731590</LicenseNumber> </Exclude> <Exclude> <CarrierName>Allstate</CarrierName> </Exclude> <Exclude> <CarrierName>State Farm</CarrierName> </Exclude> </Excludes> </DistributionDirectives> <LeadTypeID>1</LeadTypeID> <ZipCode>43215</ZipCode> <ContactInfo> <FirstName>John</FirstName> <LastName>Doe</LastName> <Address>123 E Main St</Address> <ZipCode>43215</ZipCode> <City>Columbus</City> <State>OH</State> <PhoneDay>1234567890</PhoneDay> <Email>johndoe@test.com</Email> </ContactInfo> <AutoInsurance> <Vehicles> <Vehicle> <Id>1</Id> <Vin>1G1JF31W*K*******</Vin> <Year>1989</Year> <Make>CHEV</Make> <Model>CAVALIER Z24</Model> <SubModel>_</SubModel> <Owner>Leased</Owner> <Garage>Private</Garage> <PrimaryUse>Commute School</PrimaryUse> <OneWay>85</OneWay> <AnnualMileage>25000</AnnualMileage> <Salvaged>false</Salvaged> <Comprehensive>500</Comprehensive> <Collision>2500</Collision> </Vehicle> <Vehicle> <Id>2</Id> <Vin>1FTZF08W*X*******</Vin> <Year>1999</Year> <Make>FORD</Make> <Model>F150</Model> <SubModel>_</SubModel> <Owner>Owned</Owner> <Garage>Private</Garage> <PrimaryUse>Commute School</PrimaryUse> <OneWay>62</OneWay> <AnnualMileage>50000</AnnualMileage> <Salvaged>true</Salvaged> <Comprehensive>No Coverage</Comprehensive> <Collision>250</Collision> </Vehicle> </Vehicles> <Drivers> <Driver> <Id>1</Id> <FirstName>John</FirstName> <LastName>Doe</LastName> <Gender>Male</Gender> <Marital>Domestic Partner</Marital> <DOB>1992-07-25</DOB> <Relation>Self</Relation> <DLicenseState>CT</DLicenseState> <DLicenseStatus>Temporary</DLicenseStatus> <LicensedAge>17</LicensedAge> <VehicleId>1</VehicleId> <Filing>false</Filing> <Education>Doctorate Degree</Education> <Occupation>Self Employed</Occupation> <GoodStudent>false</GoodStudent> <Suspension>false</Suspension> </Driver> <Driver> <Id>2</Id> <FirstName>Jane</FirstName> <LastName>Doe</LastName> <Gender>Female</Gender> <Marital>Married</Marital> <DOB>1988-07-25</DOB> <Relation>Other</Relation> <DLicenseState>ND</DLicenseState> <DLicenseStatus>Probation</DLicenseStatus> <LicensedAge>18</LicensedAge> <VehicleId>2</VehicleId> <Filing>false</Filing> <Education>High School Diploma</Education> <Occupation>Homemaker</Occupation> <GoodStudent>false</GoodStudent> <Suspension>false</Suspension> </Driver> </Drivers> <Incidents> <Ticket> <DriverId>1</DriverId> <Date>2010-06-25</Date> <Description>Speeding</Description> </Ticket> <Ticket> <DriverId>1</DriverId> <Date>2010-10-30</Date> <Description>Child Seat</Description> </Ticket> <Ticket> <DriverId>2</DriverId> <Date>2011-02-09</Date> <Description>Other Ticket</Description> </Ticket> <Ticket> <DriverId>2</DriverId> <Date>2008-08-29</Date> <Description>Failure to Stop</Description> </Ticket> <Ticket> <DriverId>2</DriverId> <Date>2011-02-15</Date> <Description>Child Seat</Description> </Ticket> <Claim> <DriverId>2</DriverId> <Date>2010-06-26</Date> <Description>Vandalism Damage</Description> <PaidAmount>8300</PaidAmount> </Claim> <Claim> <DriverId>2</DriverId> <Date>2009-02-27</Date> <Description>Loss Claim Not Listed</Description> <PaidAmount>700</PaidAmount> </Claim> <Claim> <DriverId>2</DriverId> <Date>2009-04-24</Date> <Description>Vehicle Stolen</Description> <PaidAmount>6900</PaidAmount> </Claim> <Claim> <DriverId>2</DriverId> <Date>2010-06-06</Date> <Description>Loss Claim Not Listed</Description> <PaidAmount>8300</PaidAmount> </Claim> </Incidents> <ApplicantInfo> <Credit>Good</Credit> <Residence>Own</Residence> </ApplicantInfo> <CurrentInsurance> <CurrentlyInsured>true</CurrentlyInsured> <CurrentPolicy> <Carrier>Nationwide</Carrier> <Expiration>2016-03-01</Expiration> <InsuredSince>2015-01-01</InsuredSince> </CurrentPolicy> </CurrentInsurance> <RequestedCoverage>Standard</RequestedCoverage> </AutoInsurance> </InsuranceRequest> '; echo $file; $url = 'http://staging.pingpost.contactability.com/api/v1/post'; $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml')); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $file ); $result = curl_exec($ch); echo $result; curl_close($ch); ?>
No comments:
Post a Comment