I'm doing a simple HTTP callout in Apex using a Named Credential with Username/Password authentication, but I'm getting a
System.CalloutException: The URI is invalid.
What could be the cause here?
String url = 'callout:NamedCredential:4326/api/Sessions.json?file=D:\Sample-Files\United Kingdom.swd'; Http h = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint(url); req.setMethod('POST'); req.setHeader('Content-Length', '0'); req.setTimeout(120000); HttpResponse response; response = h.send(req);
I have tried using
EncodingUtil.urlEncode on the URL but that doesn't help.