Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to execute 'setRequestHeader' on 'XMLHttpRequest' [...] is not a valid HTTP header field value

I am developing an application with AngularJS (client side) and Java (server side) using RESTful services (with Jersey).

In the client I have something like this

$http({
        url : "/Something/rest/...",
        method : "POST",
        headers : {
            ...
            'text' : text
        }
    });

on the server side my Java method header looks like this

 public JSONObject myMethod(@HeaderParam("text") String text [...]) throws JSONException

And I'm getting this error when trying to send a request

Error: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'Some text here formatted with \n and \t' is not a valid HTTP header field value.

Is this because of the formatting? Is it because the text is quite long?

What should I change? Please guide me

like image 282
Marius Manastireanu Avatar asked Oct 28 '25 16:10

Marius Manastireanu


1 Answers

I had faced this problem. Please make sure that in your code header name doesn't contain space. i.e. 'designId ' is invalid, as it contain space at end

like image 124
Santosh Kadam Avatar answered Oct 31 '25 07:10

Santosh Kadam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!