Can the court refuse to give me a divorce?

In some states, yes. A court can refuse to grant you a divorce if you can’t prove “grounds”. There are two types of states where divorce law is concerned. There are the fault states and the no-fault states. In the fault states you have to prove “grounds” or “marital fault” in order to get your divorce.
The “no fault” states are as follows…well, it might be easier to say what the “fault” states are: NEW YORK. All other states are “no fault” states even though some may offer other grounds for divorce if the parties choose to assert a ground. But most divorces in the United States seem to allege some permutation of “irreconcilable differences” as the basis for divorce. Except New York. That mumbo jumbo won’t work here. In New York, you must allege a “fault” and you must prove it or the judge will deny your divorce and you will have to stay married.
If your spouse won’t stipulate or agree to use a certain ground, then you have to go to trial and prove your grounds. There are statutory guidelines and certain “elements” for each ground which has to be proven in order for the judge to adjudicate you divorced. If you fail to prove these grounds, the court has to deny the divorce on the grounds you asked.
What are the grounds in New York? Check out this post: