You need to sign in to do that
Don't have an account?
Illegal Character On Callout Error
Hi Everyone,
I'm struggling with a callout that I'm trying send using a named credential and a REST query. The problem is that I keep getting a runtime error due to the > symbol. However, the >= works fine when I test it from postman. Here is a portion of my code:-
modifiedDate = '/products?where=modifieddate>=\'' + modifiedDate + '\'';
System.debug(modifiedDate);
//Poll Cin7 for changes
//Define the transaction variables.
HttpRequest req = New HttpRequest();
HttpResponse res = New HttpResponse();
Http h = New Http();
//Configure the request
req.setEndpoint('callout:Cin7' + modifiedDate);
req.setMethod('GET');
req.setTimeout(120000);
//Configure standard headers
req.setHeader('Accept', '*/*');
req.setHeader('Content-Type', 'application/json');
//Attempt the callout - Log an error on exception.
res = h.send(req);
The error that I receive is: System.CalloutException: Illegal character in opaque part at index 40: callout:Cin7/products?where=modifieddate>='2022-04-08T10:01:58.000Z'
Any ideas how to solve this?
Related https://help.salesforce.com/s/articleView?id=000362357&type=1 wherein root cause is the whitespace at the mentioned index position of the filepath.
You might want to check for any special characters too in the URL. Thanks
Thank you @Swetha,
There is no whitespace in the url, the issue seems to be with the > symbol. If I take that out and just have = it works. However, that doesn't meet my requirement of pulling all records modified since the last poll. I also tried replacing the > with it's ASCII code but that gave me a "Bad Request" error from the server.
I know it's been more than a year since the question was asked, but I had a similar issue, and it appears that the symbols '>' and '<' should be represented in a URL as '%3E' and '%3C,' respectively. It's possible that you've already resolved the issue, but at least for others like me who come across this question, they can find the answer. :)