title: JavaScript Encoding Get Request to Microsoft Dynamics CRM causing syntax error
body: <p>I need to retrieve the corresponding ID for a sectors name in our CRM application. </p>
  
  <p>I am using the CRM's API through a get request in JavaScript. I have tried using encodeURI, encodeURIComponent, and escape. The get request works with some sector names but others do not work and return an error.</p>
  
  <pre><code>//The url was masked but the query is the same.
  let URL = "http://domain/instance/api/data/v8.2/new_occurrencereportsectors?$select=new_occurrencereportsectorid,new_name&amp;$filter=new_name eq ";
  
  //This part works
  let encodedURI = encodeURI(URL);
  
  //This is the string I am trying to pass to the CRM API. This does not work.
  let query = "Ontario - Outside the Greenbelt / Ontario - à l'extérieur de la ceinture";
  
  //This is me trying out all the enocdings.
  let encodedQuery = encodeURI(query);
  encodedQuery = encodeURIComponent(encodedQuery);
  encodedQuery = escape(encodedQuery);
  
  //This is the string which I am using for the get request.
  let finalString = encodedURI + encodedQuery;
  
  //Note this is an example so I am just putting the printed.
  //URL into the search bar in the browser.
  console.log(finalString);
  </code></pre>
  
  <p>I expected the return value to be an ID which will be in the format {XXXXXXXX}.</p>
  
  <p>The output is a syntax error. Please see below for the error message. I left out the inner error because it is lengthy and I didn't see it telling anything/</p>
  
  <pre><code> "error":{
      "code":"","message":"Syntax error: character '%' is not valid at position 19 in 'new_name eq Ontario%2520-%2520Outside%2520the%2520Greenbelt%2520%2F%2520Ontario%2520-%2520%25C3%25A0%2520l'ext%25C3%25A9rieur%2520de%2520la%2520ceinture'."
  </code></pre>