1

Facing the issue into the endpoint fetching

Below is the case while I call the api get the response.

http://localhost:28080/restServices/apps/1762/users/USERNAME/?password=PASSWORD

But when ever I set following data it's not working could any body help me out into this issues.

http://localhost:28080/restServices/apps/1762/users/USERNAME/?password=PASSWORD&data={}

@RequestMapping(value = "/apps/{appId_}/users/{username_}", method = RequestMethod.GET)
@ResponseBody
@Transactional
public UserResponseDTO getUserAndToken(@PathVariable Long appId_, @PathVariable String username_, @RequestParam("password") String password_, @RequestParam("data") String datas) throws Exception {
//do stuff
}

EDIT

This problem with any edit it's works into the Tomcat Version 7.0.63 While another version 7.0.73, 8.0.x + not working.

Nimit Parekh
  • 16,776
  • 8
  • 50
  • 72

2 Answers2

0

You forgot to specify {appId_} in value = "/apps/users/{username_}"

Fix: value = "/apps/{appId_}/users/{username_}"

~~~

Your method accepts @RequestParam("data") String datas and you're sending data={} String should be quoted so the fix is data=""

sovas
  • 1,508
  • 11
  • 23
0

This kind of behaviour affect of major update of Tomcat.

For a quick fix, you can downgrade to one of older versions, I downgraded tomcat with 7.0.63 .

After getting more R&D on Spring MVC It's reject the request while adding list of invalid character into request listed below.

Excluded US-ASCII Characters disallowed within the URI syntax:

   control     = <US-ASCII coded characters 00-1F and 7F hexadecimal>
   space       = <US-ASCII coded character 20 hexadecimal>
   delims      = "<" | ">" | "#" | "%" | <">

List of unwise characters are allowed but may cause problems:

unwise      = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"

The following characters are reserved within a query component and have special meaning within a URI/URL:

  reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ","

For more information visit.

Solution:

encodeURI("http://localhost:28080/restServices/apps/1762/users/USERNAME/?password=PASSWORD&data={}")
> http://localhost:28080/restServices/apps/1762/users/USERNAME/?password=PASSWORD&data=%7B%7D
Community
  • 1
  • 1
Nimit Parekh
  • 16,776
  • 8
  • 50
  • 72