You need to sign in to do that
Don't have an account?
Salesforce Dev199
The uri is invalid error when I make a httpCallout
Hello All,
Can I get the solution for the error:
EXCEPTION_THROWN [11]|System.CalloutException: The URI is invalid.
This error is thrown when the endpoint URL has special characters like in query there is * and > symbol so it is not acceptable as proper endpoint URL.
Below is the code for the endpoint URL
In one of the POST (https://trailblazer.salesforce.com/issues_view?id=a1p4V000001JkjTQAS), it says special characters in URI are not working after Spring 21.
Any integration experts here?
Can I get the solution for the error:
EXCEPTION_THROWN [11]|System.CalloutException: The URI is invalid.
This error is thrown when the endpoint URL has special characters like in query there is * and > symbol so it is not acceptable as proper endpoint URL.
Below is the code for the endpoint URL
In one of the POST (https://trailblazer.salesforce.com/issues_view?id=a1p4V000001JkjTQAS), it says special characters in URI are not working after Spring 21.
String query='select * from Invoice where Metadata%2ECreateTime > \'2021-06-01T03:58:32.968-07:00\''; req.setEndpoint('callout:SalesforceQB_Production'+'/v3/company/xxxxxxxxxx/query?query='+query+'&minorversion=59');
Any integration experts here?
Yes, as per the investigation done around in the mentioned issue, when it was first observed in Spring 21 release, we could find that this bug is only for character - [] (not all special characters) and in the path of the URL. ([] is working in query parameters). This new behavior was an enhancement after Spring'21 release. [] falls into the unsafe category of {} and hence should be encoded.
But, in your case, when tried to debug via developer console found following is the request being made: You can try verifying the endpoint by adding a system debug in the same code to see the final request string. Then try to adhere to best pratice around using queries as parameter in API requests. And better check with simpler queries first and then with complex ones to understand it.
If you still see any discrepencies with the behavior from platform,then please consider raising a case with Salesforce support to get it reported to the product teams.
Reference:
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_search_parameterized.htm
Hope above information helps. Please mark as Best Answer so that it can help others in future.
Thanks.