Re: Invalid character found in the request target TomEE 10.0.1

Nanjangud Shivakumar Karthik <[email protected]> Fri, 11 Apr 2025 22:22:10 +0530
Newsgroups gmane.comp.java.openejb.user
Message-ID <CAFVhWXgGp_UckbjDdDxf_pY9qLTX=QJg+z_kiynCR6VY92D+eA__6704.84812451235$1744390425$gmane$org@mail.gmail.com>
--00000000000073a2aa06328386fc
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hello


*>> if you insist on GET, you need to correctly encode the json into a
query parameter.*

I still would like to use GET instead of POST ( Since the  args  submitted
is  Processing ,Filtering   the data on return , It has nothing to persist

Could u suggest on correcting to encode the Json into the Query Parameter

Json  fetched from UI

{  "searcharg": "jakarta.ws.rs.ext.Provider",  "folderfilepatharg":
"F:/TOOLS/APACHEMAVEN/MAVEN-REPO",   "searchextnarg" : "jar",
"searchstartno": 120, "searchendno": 150 }

on the Controller the method defined is as follows used to  prefilter args
to process

@GET

@Consumes(MediaType.APPLICATION_JSON)

@Produces(MediaType.APPLICATION_JSON)

@Path("/SearchBeanGet")

public SearchZipJarBean getSearchBean(SearchZipJarBean srchBean) {

loggerlog.info("Pre Process " + srchBean.toString());

....

loggerlog.info("Post Process " + srchBean.toString()); return srchZpjra
.getSrchBean();

}

with regards
N.S.Karthik

On Thu, Apr 10, 2025 at 1:56=E2=80=AFPM Richard Zowalla <[email protected]> w=
rote:

> GET with a (JSON) payload is against the RFC; a GET with a payload has no
> defined semantics:
> https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.1
>
> That being said, =E2=80=9Edata=E2=80=9C is appended to the URL as query p=
arameters, the
> content type is ignored and the JSON strings will appear (encoded) in the
> URL.
>
> I would suggest to switch to POST here =E2=80=A6 if you insist on GET, yo=
u need to
> correctly encode the json into a query parameter.
>
> > Am 10.04.2025 um 07:25 schrieb KARTHIK SHIVAKUMAR <[email protected]=
m
> >:
> >
> >
> >
> > Hello
> >
> > Spec :
> > Container : Apache TomEE PLUS -10.0.1
> > Java      : 22
> > Ide       : Eclipse IDE
> > O/s       : Win-10
> > Browser : Firefox
> > RESTClient : PostMan
> >
> > a) Process
> >      A simple Web GET request  to  REST Web Service used top parse
> Folder  and return with  results.
> >     The request fails thru the BROWSER  but passes thru RESTClient
> >
> >
> > b) Problem
> > Ajax Submission of a JSON.Stringified   on GET type  is returning  "HTT=
P
> 400 Bad Request" ( Image attached for reference )
> > As suggested  Added thy Relaxation char to the Server.xml
> >   Tomee/conf/Server.xml  : <Connector connectionTimeout=3D"20000"
> maxParameterCount=3D"1000"  port=3D"8080"  protocol=3D"HTTP/1.1"
>  redirectPort=3D"8443"
> >              server=3D"Apache TomEE"  xpoweredBy=3D"false"
> relaxedPathChars=3D" [  ] { } ^ |  "  relaxedQueryChars=3D" [ ] { } ^ |  =
"   />
> > Ajax Script :
> >                      function
> ajaxProcessContentjson(urljspVal,dataValue,httStatus){
> >                                         var InstMesg =3D '';
> >                                          $.ajax({
> >                                                type     :  "GET",
> >                                                url      :  urljspVal,
> >                                                data     :
> JSON.stringify(dataValue),
> >                                                async       :  false,
> >                                                global      :  false,
> >                                                cache       :  false,
> >                                                dataType    :  "json",
> >                                                contentType :
> "application/json",
> >                                                 success  :
> function(responseObject, textStatus, jqXHR) {
> >                                                        console.log("AJA=
X
> PASS" + jqXHR.status);
> >                                                 },
> >                                                error    :
> function(responseObject, textStatus, jqXHR) {
> >
> console.log("AJAX FAIL : " + JSON.stringify(responseObject));
> >                                                 }
> >                                                     });
> >                                                       return InstMesg;
> >                                       }
> >
> > Browser O/p
> > "{ \"searcharg\" : \"jakarta.ws.rs.ext.Provider\" ,
> \"folderfilepatharg\": \"F:/MAVEN-REPO\" , \"searchextnarg\": \"jar\" ,
> \"searchstartno\": 120 , \"searchendno\" : 150}" searchobjtest.js:17:21 <
> http://localhost:8080/SearchWebZipJar/searchobjtest/searchobjtest.js>
> > { "searcharg" : "jakarta.ws.rs.ext.Provider" , "folderfilepatharg":
> "F:/MAVEN-REPO" , "searchextnarg": "jar" , "searchstartno": 120 ,
> "searchendno" : 150}
> >
> >
> XHRGEThttp://localhost:8080/SearchWebZipJar/restapiview/cmpressapi/Search=
BeanGet?"{
> \"searcharg\" : \"jakarta.ws.rs.ext.Provider\" , \"folderfilepatharg\":
> \"F:/MAVEN-REPO\" , \"searchextnarg\": \"jar\" , \"searchstartno\": 120 ,
> \"searchendno\" : 150}"&_=3D1744261534750 <
> http://localhost:8080/SearchWebZipJar/restapiview/cmpressapi/SearchBeanGe=
t?%22%7B%20%5C%22searcharg%5C%22%20:%20%5C%22jakarta.ws.rs.ext.Provider%5C%=
22%20,%20%5C%22folderfilepatharg%5C%22:%20%5C%22F:/MAVEN-REPO%5C%22%20,%20%=
5C%22searchextnarg%5C%22:%20%5C%22jar%5C%22%20,%20%5C%22searchstartno%5C%22=
:%20120%20,%20%5C%22searchendno%5C%22%20:%20150%7D%22&_=3D1744261534750
> >
> >
> > Invalid character found in the request target
> [&#47;SearchWebZipJar&#47;restapiview&#47;cmpressapi&#47;SearchBeanGet?%2=
2{%20\\%22searcharg\\%22%20:%20\\%22jakarta.ws.rs.ext.Provider\\%22%20,%20\=
\%22folderfilepatharg\\%22:%20\\%22F:&#47;TOOLS&#47;APACHEMAVEN&#47;MAVEN-R=
EPO\\%22%20,%20\\%22searchextnarg\\%22:%20\\%22jar\\%22%20,%20\\%22searchst=
artno\\%22:%20120%20,%20\\%22searchendno\\%22%20:%20150}%22&amp;_=3D1744256=
939455
> ].
> > The valid characters are defined in RFC 7230 and RFC 3986</p>
> >
> > Question :  Chars used in json  are  . ,  { , } , /   Error caused by
>  "Invalid character found in the request"
> >
> > Please Suggest
> > --
> > with regards
> > N.S.KARTHIK
> >
>
>

--=20

*with regards*
*N.S.KARTHIK*

--00000000000073a2aa06328386fc--