On what basis? The Home Office guidelines clearly state that questioning and seizure are to be used only in cases where terrorism is suspected. David Miranda is clearly not a terrorist, nor is he associated with terrorists. To quote the guidelines:
Schedule 7 powers are to be used solely for the purpose of ascertaining if the person examined is or has been concerned in the commission, preparation or instigation of acts of terrorism. The powers must not be used to stop and question persons for any other purpose. An examination must cease and the examinee must be informed that it has ended once it has been ascertained that the person examined does not appear to be or to have been concerned in the commission, preparation or instigation of acts of terrorism.
Does the law say somewhere that they can question anyone for any purpose? If not then this was clearly illegal.