· · Matthew Ford  · 1 min read

XML to JSON API Proxy for Quick Mash-Ups

XML to JSON API Proxy for Quick Mash-Ups

While building our company dashboard, which was mentioned in our previous blog post on SVG with Raphael, I came across a problem with the project management tool we use – Pivotal Tracker.

The Pivotal Tracker API is only in XML, which means you can’t do cross-domain requests and access the API via javascript. This meant that if I wanted to extract data about the status of our user stories, I would have to do it on the server side. As everything so far had been done with javascript on the client side, I was reluctant to start making things more complicated.

I contacted Pivotal, who said they might think about adding JSON at some point, but I didn’t want to wait for them to sort it out. Instead, I built a quick API proxy that allows you to make a request to a XML API and get back JSON. So, now, I can do this in my javascript:

$.ajax({ type: "GET", url: 'https://xml2json.heroku.com', data:'url=https://www.pivotaltracker.com/services/v3/projects/'+projectId+'/iterations/current?token='+trackerToken, dataType: 'jsonp', success: function(data) { console.log(data); } });

It will proxy the GET request to the API and convert the XML response into JSON, via https://xml2json.heroku.com (supports JSONP). I’ve put the code on GitHub https://github.com/bitzesty/xml2jsonp in case anyone else needs to do the same thing.

Discuss your software, technical leadership or AI plans

Tell us what you need to build, improve or decide.

We can help with software development and ongoing support, fractional CTO leadership, and practical AI adoption. Speak to our senior team about your priorities, our approach and availability.

Back to Blog

Related Posts