I had the same error code when trying to upgrade from 8 to 8.1 on my Lenovo ThinkPad Tablet 2. It's a tablet so no LAN port, that "quick fix" isn't an option.
After trying step one of this post (http://answers.microsoft.com/en-us/windows/forum/windows8_1-windows_install/error-code-0x80240031-installing-81-from-windows/0c91e8f6-ca97-4700-a2b9-38d23c6655a8?page=1 the fourth reply in the thread) it worked with no trouble at all. I also disabled Windows Defender when I downloaded it but this works. After two days of struggle, and many many attempts at a fix, the update is finally installed and 8.1 works.
Any one with this error code on a tablet try this method. If it worked for me it will probably work for you too. Try even if you aren't using a tablet, it still might work.
Thank you Harsh Trivedi I am eternally grateful.