Even though I prefer Shanghai from a quality of life standpoint, Beijing wins hands down if you are forced to choose one or the other for a quick sampling.
There are okay airport hotels in Beijing (not really the case in Shanghai), but you owe it to yourself to stay inside 4th ring, at the very least.