The bloating is caused by the production of gas by the bacteria in your gut. If you add a lot of fiber at once, the bacteria will overpopulate, and produce too much gas, causing bloating/distension. One way to avoid this is to gradually increase the amount of fiber, so your microbiome will adjust slowly, allowing you to avoid the excess gas/bloating. Not sure what to say about the constipation, though it could be a similar issue.
These things are not simple, are they?
One strategy is to focus on the healthy veggies that your genetic ancestors likely ate; your body is more likely to be adapted to those foods.