Adding variables as a parameter in a URI or URL

I’m trying to get an object from a Back 4 App database. The URI only seem to work if I hard code the parameters.

This works:
string uri = “https://parseapi.back4app.com/classes/codes/?where={\“Code\”:\“12345\”}”;

This doesnt work:
string uri = “https://parseapi.back4app.com/classes/codes/?where={"Code":"” + code + “"}”;

I also tried with newtonsoft and still no luck:

string code = JsonConvert.SerializeObject(new { Code = codeInputField.text.ToString() });
string uri = “https://parseapi.back4app.com/classes/codes/?where=”+ code;

Before you ask the input field works perfectly. When I Debug.Log the URI using newtonsoft of the second method, it shows the uri exactly as I want it. If you have any ideas how to fix this, let me know. I’m thinking that I’m not endording the URI properly but I don’t know how to fix it

I figured it out. Apparently Text mesh Pro input field add a zero width invisible character to the text. This character is sometimes added by text editors and input fields to allow text to wrap at a certain point without breaking words apart.

My encoded string actually added that character to the URI so the database thought that the object didn’t exist. Anyways, here’s how to fix it.

code = Uri.EscapeUriString("{\"Code\":\"" + code.Replace("\u200B", "") + "\"}");

string uri = "https://parseapi.back4app.com/classes/codes/?where=" + code;