// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the LineItemCreativeAssociationService.
LineItemCreativeAssociationServiceInterface licaService =
user.getService(DfpService.V201308.LINEITEMCREATIVEASSOCIATION_SERVICE);
// Get the CreativeService.
CreativeServiceInterface creativeService =
user.getService(DfpService.V201308.CREATIVE_SERVICE);
// Set the line item ID and creative IDs to associate.
Long lineItemId = Long.parseLong("INSERT_LINE_ITEM_ID_HERE");
Long[] creativeIds = new Long[] {Long.parseLong("INSERT_CREATIVE_ID_HERE")};
// Create an array to store local LICA objects.
LineItemCreativeAssociation[] licas = new LineItemCreativeAssociation[creativeIds.length];
// For each line item, associate it with the given creative.
int i = 0;
for (Long creativeId : creativeIds) {
LineItemCreativeAssociation lica = new LineItemCreativeAssociation();
lica.setCreativeId(creativeId);
lica.setLineItemId(lineItemId);
licas[i++] = lica;
}
// Create the LICAs on the server.
licas = licaService.createLineItemCreativeAssociations(licas);
if (licas != null) {
for (LineItemCreativeAssociation lica : licas) {
System.out.println("A LICA with line item ID \"" + lica.getLineItemId()
+ "\", creative ID \"" + lica.getCreativeId() + "\", and status \""