Ok I’ve tested it with a file
URL and it fails because of (you should also have had this error in your xwiki logs BTW):
2021-05-05 15:11:37,133 [qtp5592464-14 - http://localhost:8080/xwiki/bin/view/xxx/] WARN c.x.x.a.XWiki - Failed to retrieve content from [file:///tmp/vincent.txt]
java.lang.IllegalStateException: unsupported protocol: 'file'
at org.apache.commons.httpclient.protocol.Protocol.lazyRegisterProtocol(Protocol.java:149)
at org.apache.commons.httpclient.protocol.Protocol.getProtocol(Protocol.java:117)
at org.apache.commons.httpclient.HttpHost.<init>(HttpHost.java:107)
at org.apache.commons.httpclient.HttpMethodBase.setURI(HttpMethodBase.java:280)
at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:220)
at org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:89)
at com.xpn.xwiki.XWiki.getURLContent(XWiki.java:6700)
at com.xpn.xwiki.XWiki.getURLContent(XWiki.java:6693)
at com.xpn.xwiki.api.XWiki.getURLContent(XWiki.java:2426)
So indeed my solution doesn’t work.