• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

java.lang.IllegalArgumentException: Invalid character found in the request target

 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am making a POST call like this from POSTMAN (screenshot below):



And as soon as I am making a call, I am getting following error:



Not sure why it is happening. My database guy just updated the stored procedure name that I am calling by calling the /download endpoint so I just updated the stored procedure name and a parameter name in the code. It used to work fine before making any changes.

I researched online and some people mentioned that it could be tomcat issue so I switched from version 9 to 8.5.58 locally in eclipse and it's still happening. What might be wrong?
 
Master Rancher
Posts: 4700
49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like '\' hasn't been encoded.
 
Saloon Keeper
Posts: 12428
269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's also a spurious space after the '=' of the p_user_application part of the query string.
 
Jack Tauson
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:There's also a spurious space after the '=' of the p_user_application part of the query string.



Not sure. Made some changes and it's still throwing same error:




I used to send the parameters in same fashion before without any issues.




Also tried removing space from the values of parameters p_in_project_title and p_in_project_description. No luck so far.
 
Sheriff
Posts: 22018
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:Looks like '\' hasn't been encoded.


I'm quoting this because it's still true.
 
Jack Tauson
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:

Dave Tolls wrote:Looks like '\' hasn't been encoded.


I'm quoting this because it's still true.



Should I do it like this (encode \ as %5C):

%5CABC10PCS_2015AA%5C
 
Stephan van Hulst
Saloon Keeper
Posts: 12428
269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried it?
 
Marshal
Posts: 25949
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jack Tauson wrote:Should I do it like this (encode \ as %5C):

%5CABC10PCS_2015AA%5C



Well, yes and no. You should just be URL-encoding all of the parameter values of your URL, is what you should be doing. Not asking whether specific characters should be encoded.
 
Jack Tauson
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:What happened when you tried it?



This worked fine. The eclipse didn't complain. Characters showed up as \ in the database.
 
Jack Tauson
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Jack Tauson wrote:Should I do it like this (encode \ as %5C):

%5CABC10PCS_2015AA%5C



Well, yes and no. You should just be URL-encoding all of the parameter values of your URL, is what you should be doing. Not asking whether specific characters should be encoded.



I believe when you say "URL-encoding of all of the parameter values", you mean I should do it at the time of calling the end point from UI? OR is there a way to do it in POSTMAN client as well? Thanks !
 
Stephan van Hulst
Saloon Keeper
Posts: 12428
269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure that Postman has some kind of control where you can enter request parameters and if the request is a GET request, Postman will encode the parameters in the URL for you. You shouldn't put parameters in the URL manually.

However, it appears that you are performing a request that modifies your application state. You must not use a GET request for this, but instead a POST or PUT request. The data that you want to store in the database should not be part of the URL, but rather of the request body.
 
Jack Tauson
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:I'm pretty sure that Postman has some kind of control where you can enter request parameters and if the request is a GET request, Postman will encode the parameters in the URL for you. You shouldn't put parameters in the URL manually.

However, it appears that you are performing a request that modifies your application state. You must not use a GET request for this, but instead a POST or PUT request. The data that you want to store in the database should not be part of the URL, but rather of the request body.



Thank you.

The data that you want to store in the database should not be part of the URL, but rather of the request body.


I was thinking about this. I would appreciate if I could get some more advise on this.

While calling the download endpoint, I am calling the stored procedure in my code and that needs parameters and hence I decided to use it like GET request. I mean, the data which is the part of the URL is not directly getting saved into the database. Could you tell me if this scenario is still good or do I still need to consider sending the data as a part of request body? Thanks again !
 
Stephan van Hulst
Saloon Keeper
Posts: 12428
269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A GET request is appropriate.
 
Yeah, but how did the squirrel get in there? Was it because of the tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic