I am trying to encode the following URL with UTF-8 and tried to execute, but I got the “BadRequest” response.
https://api.atlassian.com/ex/confluence/my-client-id/rest/api/content/search?cql=lastmodified>="2021/10/01 19:57" AND lastmodified<"2022/02/18 06:56"&expand=version,history.previousVersion
Version 1: https://api.atlassian.com/ex/confluence/my-client-id/rest/api/content/search?cql%3Dlastmodified%3E%3D%222021%2F10%2F01+19%3A57%22+AND+lastmodified%3C%222022%2F02%2F18+06%3A56%22%26expand%3Dversion%2Chistory.previousVersion
Version 2: https%3A%2F%2Fapi.atlassian.com%2Fex%2Fconfluence%2Fmy-client-id%2Frest%2Fapi%2Fcontent%2Fsearch%3Fcql%3Dlastmodified%3E%3D%222021%2F10%2F01+19%3A57%22+AND+lastmodified%3C%222022%2F02%2F18+06%3A56%22%26expand%3Dversion%2Chistory.previousVersion
Neither of the above have worked.
May I know the correct way to format the query url?
The URL encoding of lastmodified >= "2021/10/01 19:57" AND lastmodified < "2022/02/18 06:56" is lastmodified%20%3E%3D%20%222021%2F10%2F01%2019%3A57%22%20AND%20lastmodified%20%3C%20%222022%2F02%2F18%2006%3A56%22 so try invoking with:
Most tech stacks provide utilities to encode URLs. For example, for Javascript you would call encodeURIComponent('lastmodified >= "2021/10/01 19:57" AND lastmodified < "2022/02/18 06:56"'). See encodeURIComponent() - JavaScript | MDN.