Equivalent of tf.train.Example.SerializeToString(python) in Java?

I am trying to execute a TF saved model in Java and running into the following exception:

Exception in thread "main" org.tensorflow.exceptions.TFInvalidArgumentException: Could not parse example input, value: 
     [[{{node ParseExample/ParseExampleV2}}]]
    at org.tensorflow.internal.c_api.AbstractTF_Status.throwExceptionIfNotOK(AbstractTF_Status.java:87)
    at org.tensorflow.Session.run(Session.java:850)
    at org.tensorflow.Session.access$300(Session.java:82)
    at org.tensorflow.Session$Runner.runHelper(Session.java:552)
    at org.tensorflow.Session$Runner.runNoInit(Session.java:499)
    at org.tensorflow.Session$Runner.run(Session.java:495)
    at org.tensorflow.SessionFunction.call(SessionFunction.java:116)
    at org.tensorflow.TensorFunction.call(TensorFunction.java:84)

I have this python code to execute the model, which work fine and yields the corrects result (Works fine):

num_columns = {k: tf.train.Feature(float_list=tf.train.FloatList(value=[v])) for k, v in request.features.items() if not k.endswith("_indx")}
indx_columns = {k: tf.train.Feature(int64_list=tf.train.Int64List(value=[v])) for k, v in request.features.items() if k.endswith("_indx")}
example_dict = {**num_columns, **indx_columns}


example = tf.train.Example(features=tf.train.Features(feature=example_dict))
return model.signatures["serving_default"](inputs=tf.constant([example.SerializeToString()]))[
        'outputs'].numpy().flatten()

Equivaltent java code is throwing an error(Gives the above exception):

for(String key : request.keySet()) {
            if (key.contains("_indx")) {
                Int64List data = Int64List.newBuilder().addValue(Long.parseLong(request.get(key).toString())).build();
                Feature temp = Feature.newBuilder().setInt64List(data).build();
                modelFeatures.put(key,temp);
            }
            else {
                FloatList data = FloatList.newBuilder().addValue(Float.parseFloat(request.get(key).toString())).build();
                Feature temp = Feature.newBuilder().setFloatList(data).build();
                modelFeatures.put(key,temp);
            }
}
Features features = Features.newBuilder().putAllFeature(modelFeatures).build();
Example example = Example.newBuilder().setFeatures(features).build();
String modelInput = example.toByteString().toString("UTF-8");
TString t = TString.scalarOf(modelInput);
Tensor op = savedModelBundle.function("serving_default").call(t);

tf.train.Example.SerializeToString & example.toByteString().toString(“UTF-8”) is it the same? How do I pass the example to model in the right binary format in java?