Sex in late pregnancy

Can sex put you into labour at 35 weeks? Last time we had sex I was getting period cramps in my back all night so unsure if it’s safe or not?