tHttpRequest an tRest : error 400 Bad Request when special character blank space

Five Stars

tHttpRequest an tRest : error 400 Bad Request when special character blank space

Hello,

I'm using a tHttpRequest in GET mode. when I send a link without spaces or special characters like "€", it works very well. As soon as there is a space or other special character in my data it returns me a message "400 bad request". When I put the same link on an explorer it goes very well. I also tried with a tRest but I have the same message. I tried to make an URLEncoder.encode in UTF-8, but here it crashes.

Can you help me please ?

Screenshot_1.png

Five Stars

Re: tHttpRequest an tRest : error 400 Bad Request when special character blank space

Any help ?

Three Stars

Re: tHttpRequest an tRest : error 400 Bad Request when special character blank space

Hello,

I have almost the same type of error.

I'm trying to send an OData query via tRest component, and have a filter like "CFISCYEAR eq 2018" in my URL.

Because of the spaces I have in this filter, I get a java.lang error : IllegalArgumentException: Illegal character in query at index 146.

 

Any help would be welcome and appreciated Smiley Happy

Sixteen Stars

Re: tHttpRequest an tRest : error 400 Bad Request when special character blank space

Wrap your URL within this code.....

java.net.URLEncoder.encode(yourURL, "UTF-8") 
Three Stars

Re: tHttpRequest an tRest : error 400 Bad Request when special character blank space

Thank you for your reply.

Unfortunately, it's not working for me : 

com.sun.jersey.api.client.ClientHandlerException: java.lang.IllegalArgumentException: URI is not absolute

Sixteen Stars

Re: tHttpRequest an tRest : error 400 Bad Request when special character blank space

Yours is a completely different issue. Can you raise a new question and include screenshots of your configuration. There is not enough information here.

Three Stars

Re: tHttpRequest an tRest : error 400 Bad Request when special character blank space

Five Stars

Re: tHttpRequest an tRest : error 400 Bad Request when special character blank space

The Encode function does not work because it will encode anything even the "/"

Sixteen Stars

Re: tHttpRequest an tRest : error 400 Bad Request when special character blank space

Yes @jarmoud_4 I went into more detail here: https://community.talend.com/t5/Design-and-Development/tRest-using-OData-URL-with-blank-space/m-p/11...

 

I was kind of expecting it to be more of a clue than an unquestioned solution, if I am honest. Essentially you need to encode everything that is not a functional part of the URL. This means that in URLs with parameters built in, it may only just be the parameter sections.