The German invasion of Norway in 1940 led to Andersen's life once more taking a turn into illegal activities. His furniture workshop was used as a weapons depot by the Norwegian resistance movement, and he took part in looting German military stores. He was first arrested by the Germans after he had responded to rumours that he was a Nazi by writing the Norwegian national socialist party Nasjonal Samling's official publication "Fritt Folk" and stating that "although I have done many wrong things in my life, a Nazi I am not. Yours sincerely Johs. S. Andersen". The letter was published unedited by the newspaper, although Andersen was later arrested by the occupying authorities and sentenced to one year in prison, after spending half a year in detention. Using techniques he had learned during his earlier criminal career, Andersen managed to be transferred to prison hospital during his time in detention. While there he acquired false x-ray images and tuberculosis germs to fake illnesses in other captured resistance men who were on their way to interrogation. He also infected a German interrogator with malaria by contaminating his insulin. At night, he would sneak out of the hospital and operate in Oslo, amongst other activities breaking into Nasjonal Samling offices and stealing documents, copying them and having them shipped to the United Kingdom together with evidence of torture in Nazi-run prisons. He served the last part of his sentence in Fuhlsbüttel near Hamburg, Germany. His wife was also active in resistance work, dealing with propaganda and espionage. Author Egil Ulateig doubts the veracity of Andersen's prison exploits, which are based mostly on Andersen's own testimony.