Ich versuche mit der routexl API ein Skript zu erstellen, das die schnellste Route zum Übergeben mehrerer Standorte ausarbeitet. Alles, was ich versuche, scheint jedoch mit einem Fehler 409 Truncated Server Response zu kommen. Mein Code ist wie folgt.Google Script API routexl Fehler 409
function myFunctionpost() {
var url = "https://api.routexl.nl/distances";
var places = [{"address":"1","lat":"52.05429","lng":"4.248618"},{"address":"2","lat":"52.076892","lng":"4.26975"},{"address":"3","lat":"51.669946","lng":"5.61852"}];
var locations = JSON.stringify(places);
var headers = {
"Authorization":"Basic " + Utilities.base64Encode("Username:password"),
"Content-Type":"application/json"
};
var options = {
'method' : 'post',
'headers' : headers,
'contentType': 'application/json',
'payload' : locations,
'muteHttpExceptions' : true
};
var response = UrlFetchApp.fetch(url, options);
//var json = response.getContentText();
//var data = JSON.parse(json);
Logger.log(response);
}
hinzufügen 'muteHttpExceptions: true', um Ihre Optionen. A 409 könnte bedeuten, dass der Dienst Ihre Nutzlast nicht mag. Wenn muteHttpExceptions aktiviert ist, können weitere Daten in der Antwort vorhanden sein. –
Danke @SpencerEaston Ich habe das hinzugefügt, wie Sie vorgeschlagen haben, was mir eine weitere Ausgabe von 'Syntax Error, Unexpected Token: N' in der Zeile 'var data = JSON.parse (json);' gab um die Antwort zu protokollieren. Die neue Information, die wir in den Logs erhalten haben, lautet 'No input found'. – codeacker