function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ZAPEXZAPEX 

System.CalloutException: The URI is invalid.

I am getting System.CalloutException: The URI is invalid when I am calling a Rest endpoint with spaces.
The endpoint I am trying to call looks like this and it has spaces
...../CUSTOMERS?$orderby=CUST asc&$top=100&$filter=CUST gt 0
unfortunately, apex see this as invalid URI.
I tried URL encode but then the service I am calling returned an error. so the call has to include the spaces in the URI
I also tried to set header to 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' although I saw it used only for POST and PUT while I am doing GET

any idea how to resolve?