The System.Web.HttpUtility.UrlEncode method can be used to encode the URL in set-url. Attempt the following code:
<send-request mode="new" response-variable-name="bearerToken" timeout="20" ignore-error="true">
<set-url>@{
string baseUrl = "https://url/api/data/v9.2/data?$select=d1,d2,d3&$filter=d2 eq 'data'";
string encodedUrl = System.Web.HttpUtility.UrlEncode(baseUrl);
return encodedUrl;
}</set-url>
<set-method>POST</set-method>
<set-header name="Content-Type" exists-action="override">
<value>application/x-www-form-urlencoded</value>
</set-header>
<set-body>@{ return "url"; }</set-body>
</send-request>
This should correctly encode the URL and eliminate any issues with spaces or special characters.