Invalid Document Reference. Document References Must Have An Even Number Of Segments
I am querying a collection for documents using below code. Document names are same as device names. The device name is passed to the document from an API I am getting an error when
Solution 1:
try this
response.body().get(finalI).getDeviceName().toString().replace("/","_")
Solution 2:
The simplest method I can think of, is before you add the data to the database to find that forbidden /
symbol and replace it with an allowed one, let's say -
(minus).
String deviceName = response.body().get(finalI).getDeviceName().replaceAll("/", "-");
And then simply use in your reference like this:
firebaseFirestore.collection("Mobiles").document(deviceName);
Post a Comment for "Invalid Document Reference. Document References Must Have An Even Number Of Segments"