take the rap be punished or blamed, especially for something that is not your fault or for which others are equally responsible.
☞ The late 18th-century use of rap to mean 'criticism' or 'rebuke' was extended in early 20th-century American English to include 'a criminal charge' and 'a prison sentence'. Compare with take the fall (atfall)