Tour API via AngularJS ($http.post) returns 409, Conflict, No input found

Hi,

I’m about evaluating the service before buying a long term subscription but I’m facing some problems. 

From PostMan the tour API works correctly, but calling it from angularjs $http s.g. goes wrong. It always returns 409.

Here is the JS snippet I use:
(sorry for the screen shots, I wasn’t able to format my code in the editor)

The Request Payload looks like this (Chrome Dev Tools) 

Request Headers:

Could you please suggest me a way to pass the data correctly? I’m pretty sure I do s.g. wrong when passing the data to the $http service. 
 
If I copy the payload value to PostMan it runs without error. 

The difference between the API doc and my code is that after the locations kay I have a “:” instead of “=”. Can it be the problem??? 

I also tried with ‘Content-Type’: ‘application/x-www-form-urlencoded; charset=utf-8’ header, no success… 

Info: Calling Status via $http.get works nicely. 

Thank you in advance. 

– cs.

The 409 indicates that the locations are not found. I am no AngularJS expert, but it seems like you’re sending data while our API expects parameters. You could try to use “params” instead of “data” in the config object.

https://docs.angularjs.org/api/ng/ser…

We’d like to check in detail in our testing environment. Please send the parameter to info@routexl.com

We have discussed this issue via email and have not succeeded in getting AngularJS $http to work with our API.

However, cseguyd found the routexl-api.js file in our RouteXL API Connector Github project:
https://github.com/routexl/RouteXL-AP…

This file works like a charm and he managed to integrate it into AngularJS.

Hi,

Thank you for the quick answer. 

Now I pass it as a query string.

params: { locations: JSON.stringify($scope.addresses) }

And now I have this as parameter:

But I still get the same error… :( 

Yes, that’s the case, it’s working now seamlessly.
Thank you for sharing the solution. :) 

Best.