On commercial flights, pilots are usually required to have different meal, to reduce the chance of food poisoning affecting both pilots.
Is this just a precautionary measure, or has this actually occurred?
Pilot incapacitation due to food poisoning does appear to have occurred.
The linked question, Is it true that the pilot and co-pilot are required to eat different meals? contains this New York Times article, which describes one incident:
(However, this may not be quite what you're looking for, as being a single crew plane, it's unlikely he consumed the meal on-board).
The article also describes a number of near misses:
Note the NYT article is dated 1984, so there could have been lots more incidents since then. For example, a search of the Aviation Herald for "food poison" brings up a number. While you need to read each one and determine if the food poisoning came from the food on board, prior to the flight, or was unconfirmed as the cause, an incident of an inflight meal incapacitating the first officer occurred in a Boeing 737-800 as recently as Nov 18, 2016, flying from Spain to Denmark. In this incident, it is stated that the crew were served different meals.
It says: A chef subsequently informed the first officer that a part of her flight crew meal (cabbage stew) most likely was the source of the food poisoning. Because the cabbage grows in contact with soil, and since it most likely was only heated and not cooked during preparation, live microbiological bacteria might have been present in the hot meal.