Javascript Rest Example for cross-domain access

Hi guys,

Ive been struggling with getting access to the JSON REST API from a cross-domain address. Do you have any examples in javascript for accessing the REST JSON API? It would be a huge help!

Thanks,
-Stewart

6 comments
Comment actions Permalink

Stewart,

No examples at this time. If you manage to get your and publish it - we will get one :)

I believe cross-domain access from the browser will not be possible unless REST API supports JSONP which it does not so far.

0
Comment actions Permalink

Is anyone in your team investigating support for JSONP? It could be as simple as all the REST scripts taking an optional jsonpkey="somefunction" and then auto returning jsonp padding with function "somefunction" and header "application/json" or "application/x-json"...

I would think with the growth of HTML5 technologies this would be something alot of people can benifit from. Myself included of course ;)

Would your company even consider some sort of partnership in-order to implement these features into existing scripts? (dependent on magnitude of course

0
Comment actions Permalink

Stewart,

There is no ongoing work on JASONP support and we just need to find time to dedicate it to the task (provided we have many other requests and tasks : )
Will probably try to look into that, but I cannot guarantee any timeframes so far.

As to partnership - as the REST API plugin is open-source, everyone is welcome to submit patches to us that we can then review and integrate into the main codebase.

0
Comment actions Permalink

Can I just confirm that, 100%, there is no way to use (for example) jQuery AJAX calls to access the TeamCity REST API if the TC is an a different domain to the calling Javascript code?

0
Comment actions Permalink

There is a related issue in the traker to support CORS.

BTW, I've investigated options of adding JASONP support, but so far found no elegant way to do that with the Jersey library which is currently in use. Seems like using suggested solution one would need to change all the resource methods which is suboptimal. At some point will try to look into other options.

0
Comment actions Permalink

Thank you for getting back to me on this, very much appreciated.

As an alternative, I can look into using another library e.g. TeamCitySharp to help me with my solution.

0

Please sign in to leave a comment.