Make sure there is only the new drive in your iMac when installing it. "No other drive connected" to your iMac. 3.5" Western digital hard-drive removed from an iMac 27" (production date 02/2012). Hard-drives in iMac are compatible, just instal, power-on and press the option key so the Mac will recognize the new hard drive.
eBay