HSG test question

If I want to do an IUI, do I have to do the HSG test before I can? Is it mandatory??