Re: Invalid character found in the request target TomEE 10.0.1
Richard Zowalla <[email protected]> Thu, 10 Apr 2025 10:26:13 +0200
| Newsgroups | gmane.comp.java.openejb.user |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_141286E1-21BB-4D28-A9EE-D6FD4D21FDC4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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 = parameters, 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, = you need to correctly encode the json into a query parameter. > Am 10.04.2025 um 07:25 schrieb KARTHIK SHIVAKUMAR = <[email protected]>: >=20 >=20 >=20 > Hello >=20 > Spec :=20 > Container : Apache TomEE PLUS -10.0.1 > Java : 22 > Ide : Eclipse IDE > O/s : Win-10 > Browser : Firefox > RESTClient : PostMan >=20 > 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 >=20 >=20 > b) Problem > Ajax Submission of a JSON.Stringified on GET type is returning = "HTTP 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 : =20 > function = ajaxProcessContentjson(urljspVal,dataValue,httStatus){ > var InstMesg =3D ''; > $.ajax({ > type : "GET", > url : urljspVal,=20= > data : = JSON.stringify(dataValue), > async : false, > global : false, > cache : false,=20= > dataType : "json",=20= > contentType : = "application/json",=20 > success : = function(responseObject, textStatus, jqXHR) {=20 > = console.log("AJAX PASS" + jqXHR.status); > }, > error : = function(responseObject, textStatus, jqXHR) { > = console.log("AJAX FAIL : " + JSON.stringify(responseObject));=20 > } > }); > return InstMesg; > } >=20 > 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} >=20 > = XHRGEThttp://localhost:8080/SearchWebZipJar/restapiview/cmpressapi/SearchB= eanGet?"{ \"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,%2= 0%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= > >=20 > Invalid character found in the request target = [/SearchWebZipJar/restapiview/cmpressapi/SearchBeanGet?%22= {%20\\%22searcharg\\%22%20:%20\\%22jakarta.ws.rs.ext.Provider\\%22%20,%20\= \%22folderfilepatharg\\%22:%20\\%22F:/TOOLS/APACHEMAVEN/MAVEN-= REPO\\%22%20,%20\\%22searchextnarg\\%22:%20\\%22jar\\%22%20,%20\\%22search= startno\\%22:%20120%20,%20\\%22searchendno\\%22%20:%20150}%22&_=3D1744= 256939455 ].=20 > The valid characters are defined in RFC 7230 and RFC 3986</p> >=20 > Question : Chars used in json are . , { , } , / Error caused by = "Invalid character found in the request" >=20 > Please Suggest > -- > with regards > N.S.KARTHIK >=20 --Apple-Mail=_141286E1-21BB-4D28-A9EE-D6FD4D21FDC4--