Seems to be working fine on 
http://playground.xwiki.org/xwiki/bin/view/Main/Aaron

Maybe there was a problem specifically on 6.2RC1 (BTW better use some final 
releases…:)). I’d recommend 6.4.5 for the 6.x cycle.

Thanks
-Vincent

On 15 Sep 2015 at 18:53:16, Aaron Hardy at AC ([email protected]) 
wrote:

Page syntax is XWiki 2.1 and the velocity is wrapped. Sorry, I didn't include 
the full code for simplicity's sake. Here's a minimal example cut and pasted 
from the editor (only thing changed is the actual URL):

*******************************
{{velocity}}

  #set($getURL = "https://www.example.com/api/example.mhtml?param=123";)
  $getURL

  #set($content = $xwiki.getURLContent($getURL))
  $content

{{/velocity}}

If I set $getURL to "https://google.com";, it prints $content to the page. With 
my API URL, I get nothing but the link in $getURL. But if I follow that link, I 
get the expected XML page from the API, so I know the URL is working correctly.

I figured it was because $content is XML from the API, and HTML from google, 
but using $services.xml.parse on the response doesn't work either.

The strange part is that this is code that I haven't touched in quite some 
time, and used to be working. The full code parses the XML response and saves 
various elements to an HTML table on the page - but it doesn't appear to be 
getting that far.



On Tue, Sep 15, 2015 at 12:41 PM, [email protected] <[email protected]> wrote:
Hi Aaron,


On 15 Sep 2015 at 18:38:17, Aaron Hardy at AC 
([email protected](mailto:[email protected])) wrote:

> XWiki 6.2RC1. I have some velocity code using getURLContent() to access an
> external API that appears to not be working after a server move, despite
> working in the past.
>
> Something like this used to work:
>
> *****************************
> #set($url = "https://www.example.com/api/example.mhtml?param=123";)
> #set($response = $xwiki.getURLContent($url))
>
> #if ($response)
> #set($tags = $services.xml.parse($response).getElementsByTagName('TAG'))
> $tags.length
> #end
> *****************************
>
> Now, $response appears to be empty (nothing appears when written to the
> page). Going directly to the API URL returns properly formatted XML, so I
> know the API itself is working. And changing $url to http://google.com also
> returns data.
>
> Any ideas?

What is the syntax of your page? Are you sure it’s XWiki Syntax 2.0+ and you’re 
wrapping the velocity content with the {{velocity}} macro for example (you 
didn’t show it in your example). 

$response is still there

Thanks
-Vincent

> aaron


_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to