The word "шапка" is feminine, therefore "my" has to be translated as "моя".
Also, it has to be in Nominative (шапка), шапку is Accusative.
"Мій капелюх" is accepted.
If your answer wasn't accepted, it happened for some other reason. Maybe you put "моя", I wouldn't know. I cannot tell you for what reason because you didn't provide your answer here. Please always provide your full answer in the comment if you have a question about why it wasn't accepted.