Agent calls readpeaker api and gets 302 document has moved

however calling the same api url from postman (chrome plugin to simulate get/post requests) it works ok

my agent code following github example
`
url <- format(“http://tts.readspeaker.com/a/speak?%s”, http.urlencode(data));
server.log(url);
headers<-{ “Content-Type” : “text/xml” };
http.get(url,headers).sendasync(function(resp) {

if (resp.statuscode == 200) {
    server.log("sending audio to imp");
    //device.send("audio", resp.body);
} else {
    server.log(format("ERROR %li: %s", resp.statuscode, resp.body));
}

});
`

the error

this is the server.log(url)
http://tts.readspeaker.com/a/speak?voice=Male01&text=%20i%20am%20glad%20to%20meet%20you&sampledepth=8&audioformat=alaw&command=produce&lang=en_us&samplerate=16000&container=none&key=xxxxxx

than the server.log(format(“ERROR %li: %s”, resp.statuscode, resp.body));

2014-08-12 22:21:30 UTC+1 [Agent] ERROR 302: The document has moved a href=“http://rstts.readspeaker.com/cgi-bin/nph-readspeaker/9b5ff9e4f992c5f31.alaw”>here.

The agent won’t automagically redirect (which is what a 302 response is).

It looks like their API endpoints, or how they return data has changed. When you get that 302 response, you’ll want to grab out the URL (it’s likely in a header as well), and then make a request to that endpoint.