0

Calling a webservice url is always causing me a 404 when calling my url like this

service.getAddress = function(address){
  var encodedSearch = encodeURIComponent(address) + "%5C";
  var args = {
      'address': encodedSearch,
      'callback': 'JSON_CALLBACK',
      'language': $translate.use()
    },
    params = (args.language + "/" + args.address + '?callback=' + args.callback);
  return $http.jsonp(ADDRESS_LOOKUP_ENDPOINT + params);
};

My address string can be like "80/85 Main Street"

URL looks like

http://myurl.com/Service/api/findmyaddress/en/APARTMENT%203,86/88%20NARNIA%20ROAD,CALI%204%5C?callback=angular.callbacks._3

The encodeURIComponent is turning "/" slashes into "%2F" but it causes a 404.

I have tried different things i.e. "%252F"

But also causing a 404

StevieB
  • 6,263
  • 38
  • 108
  • 193

2 Answers2

1

You could try to use

encodeURI()

to better handle your request

Carsten
  • 4,005
  • 21
  • 28
  • Still getting 404, is this because it's a restful url and can't have a "/" in one the values of the parameters ? – StevieB Jun 22 '15 at 11:35
1

Why not try encodeURI function instead of encodeURIComponent?

Mothupally
  • 750
  • 2
  • 8
  • 16
  • Are you able to get the response when the url is accessed from a browser? Can you paste your complete url to further investigate? – Mothupally Jun 22 '15 at 11:45
  • Something like this http://myurl.com/Service/api/findmyaddress/en/APARTMENT%203,86/88%20NARNIA%20ROAD,CALI%204%5C?callback=angular.callbacks._3 – StevieB Jun 22 '15 at 11:48
  • the 86/88 is making it fall over – StevieB Jun 22 '15 at 11:48
  • what is the webserver and service technology being used? you would probably need to let the webserver read the url only till en and the rest being considered as a resource. – Mothupally Jun 22 '15 at 12:02
  • IIS and .NET 4 on the server – StevieB Jun 22 '15 at 12:06
  • Can you check if you could use the solution mention here http://stackoverflow.com/questions/6328713/urls-with-slash-in-parameter – Mothupally Jun 22 '15 at 12:20