The city state has to have the tech and the proper improvements before they will gift it to you. I've had instances where a coal resource is sitting on a mined hill. The allied city state shows coal on their resource list, but I still didn't get the resource and I can't pay to improve the said tile because it's already mined.
Makes sense, I believed it was a bug