When Adi Shankara defeated Mandana Mishra, his wife Ubhaya Bharati said he also have to defeat her in debate. In order to turn the debate towards her, she started asking about Kama Shastra. But as a celibate Shankara knew nothing about Kama Shastra. So, he asked one month time to learn Kama Shastra which was accepted by Ubhaya Bharati. Then Shankara entered the body of a king who is about to die and learnt Kaama Shastra.
Now, many people say as a Sanyasi, Shankara never did this act. So this might be a story created by disciples of Shankara. My question is, in which book this story is mentioned first?