Paul and James were quoting the exact same verse in Genesis when they wrote:
"Was not Abraham our father justified by works when he offered up Isaac his son on the altar? 22 You see that faith was working with his works, and as a result of the works, faith was perfected; 23 and the Scripture was fulfilled which says, “And Abraham believed God, and it was reckoned to him as righteousness,” and he was called the friend of God. 24 You see that a man is justified by works and not by faith alone." (James 2:21-24)
"For if Abraham was justified by works, he has something to boast about, but not before God. 3 For what does the Scripture say? “Abraham believed God, and it was credited to him as righteousness.” 4 Now to the one who works, his wage is not credited as a favor, but as what is due. 5 But to the one who does not work, but believes in Him who justifies the ungodly, his faith is credited as righteousness," (Romans 4:2-5)
Were Paul and James contradicting each other? Not at all.