// Create a line item. LineItem lineItem = new LineItem(); // lineItem.setSomeThings(...); try { // Create the line item on the server. lineItemService.createLineItems(new LineItem[] {lineItem}); } catch (ApiException e) { ApiError[] apiErrors = e.getErrors(); for (ApiError apiError : apiErrors) { StringBuilder errorMessage = new StringBuilder(); errorMessage.append(String.format( "There was an error of type '%s', on the field '%s'," + "caused by an invalid " + "value '%s', with the error message '%s'", apiError.getApiErrorType(), apiError.getFieldPath(), apiError.getTrigger(), apiError.getErrorString())); if (apiError instanceof NotNullError) { errorMessage.append(String.format(", with the reason '%s'.", ((NotNullError) apiError).getReason())); } else if (apiError instanceof FrequencyCapError) { errorMessage.append(String.format(", with the reason '%s'.", ((FrequencyCapError) apiError).getReason())); } // Append details of other ApiErrors that you are interested in. System.err.println(errorMessage.toString()); } }
There was an error of type 'NotNullError', on the field 'lineItem[0].orderId', caused by an invalid value '', with the error message 'NotNullError.NULL', with the reason 'NULL'.
There was an error of type 'FrequencyCapError', on the field 'lineItem[0].frequencyCaps', caused by an invalid value '1000', with the error message 'FrequencyCapError.RANGE_LIMIT_EXCEEDED', with the reason 'RANGE_LIMIT_EXCEEDED'.There was an error of type 'FrequencyCapError', on the field 'lineItem[0].frequencyCaps', caused by an invalid value '0', with the error message 'FrequencyCapError.IMPRESSIONS_TOO_LOW', with the reason 'IMPRESSIONS_TOO_LOW'.
requestId