The story of St. James and Hermogenes is part of the The Golden Legend or Lives of the Saints, compiled by Jacobus de Voragine, Archbishop of Genoa, 1275; first edition published 1470; translated by William Caxton, first edition 1483. A small section repeated here:

The Magician Hermogenes by Pieter Van Der Heyden after a design by Pieter Bruegel

Upon his return to Judea, [James] again began to preach the word of God. Then the Pharisees asked a magician named Hermogenes to send his disciple Philetus to confront James, and to convict him of the falsity of his doctrine before the Jews. But on the contrary, James reasoned with Philetus and performed many miracles before his eyes, and in the end converted him, which all the people saw: and Philetus, when he returned to his master, praised James’s doctrine, recounted his miracles, proclaimed that he would become his disciple, and urged Hermogenes to follow his example. Then the magician, angered at this, wrought his magical arts upon Philetus, and deprived him of the power to move; and he said: ‘Now we shall see whether thy James can deliver thee!’ But when Philetus sent his servant to make this known to James, the apostle sent him his kerchief, saying: ‘Let him take this kerchief, and say: “The Lord lifts up them that fall, and looses the captives.”‘

And no sooner had Philetus touched the kerchief than he was freed from his magical bonds, hurled insults at Hermogenes, and hastened to rejoin the apostle. Enraged, Hermogenes ordered the demon to bring James and Philetus to him loaded with chains, that he might take his revenge upon him, and deter his disciples from similarly insulting him. But when the demons flew through the air and came to James, they began to howl and cry out: ‘Apostle James, have pity on us, for behold we burn before our time!’ And James said to them: ‘To what end come ye here.?’ And the demons responded: ‘Hermogenes sent us to lay hold of thee and of Philetus; but all at once the angel of God bound us with fiery chains, and ceases not to torture us.’ ‘Let the angel of God release you,’ said James, ‘but only on condition that ye bind Hermogenes and bring him to me unharmed.’

And the demons went and seized Hermogenes, and bound his hands behind his back, and brought him thus bound to James, saying to him: ‘Thou hast sent us to be burned and grievously tormented!’ And the demons said to James: ‘Give us power over him, that we may avenge thine insults and our burnings!’ And James said to them: ‘Here is Philetus before you: why do you not lay hands on him?’ And they answered: ‘We cannot touch so much as an ant that is in thy chamber!’ And James said to Philetus: ‘Let us follow the example of Christ, Who taught that we should return good for evil. Hermogenes bound thee: ‘do thou free him!’

And when Hermogenes stood before him, freed of his chains and covered with confusion, James said to him: ‘Go freely wherever thou wilt, for our law does not allow that one be converted unwillingly!’ And Hermogenes replied: ‘I know the vengeful spirit of the demons! They will kill me unless thou give me something that belongs to thee, as a safeguard.’ Then James gave him his staff, and he went off, and brought his books of magic to the apostle to be burnt. But James, fearing lest the smoke of them do some harm to the unwary, commanded him to throw them into the sea. And when he had done this, he returned and threw himself at the apostle’s feet, saying: ‘Thou who dost set souls free, receive as a penitent him whom thou hast succored even when he envied and slandered thee!’ And thenceforth he became perfect in the fear of God.