// Set the IDs of the companies for the contacts.
Long advertiserCompanyId = Long.parseLong("INSERT_ADVERTISER_COMPANY_ID_HERE");
Long agencyCompanyId = Long.parseLong("INSERT_AGENCY_COMPANY_ID_HERE");
// Create an advertiser contact.
Contact advertiserContact = new Contact();
advertiserContact.setName("Mr. Advertiser #" + new Random().nextLong());
advertiserContact.setEmail("advertiser@advertising.com");
advertiserContact.setCompanyId(advertiserCompanyId);
// Create an agency contact.
Contact agencyContact = new Contact();
agencyContact.setName("Ms. Agency #" + new Random().nextLong());
agencyContact.setEmail("agency@agencies.com");
agencyContact.setCompanyId(agencyCompanyId);
// Create the contacts on the server.
Contact[] contacts =
contactService.createContacts(new Contact[] {advertiserContact, agencyContact});