Web API: Invalid header field name

ForumCategory: QuestionsWeb API: Invalid header field name
boeledi asked 6 years ago

Hi,
I am new to Flutter and I am trying to call my ASP.NET server web API.
From the logs on my server, everything goes fine but Android Studio throws an exception: “invalid header field name”.
Here is the code in dart:

_getService()  async {
String result;
try {
var url = 'http://192.168.1.14:34263/api/Mobile/test/1';
Future<http.Response> response = http.get( url );
result = response.toString();
} catch(exception){
result = exception.toString();
debugPrint(result);
}
...
}

Here is the response header (obtained via Chrome):

Access-Control-Allow-Headers:accept, authorization, Content-Type
Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: WWW-Authenticate
Cache-Control: no-cache
Content-Encoding: deflate
Content-Length:79
Content-Type: application/xml; charset=utf-8
Date: Thu, 08 Mar 2018 01:01:25 GMT
Expires:-1
Pragma:no-cache
Server:MyTestServer
X-Content-Type-Options:NOSNIFF
X-Permitted-Cross-Domain-Policies:master-only
X-SourceFiles:=?UTF-8?BDpcTXlJbmNyZWRpYmxlRHJlc3NpbmdcTXlJbmNyZWRpYmxlRHJlc3NpbmdcTXlJbmNyZWRpYmxlRHJlc3NpbmdcYXBpXE1vYmlsZVxjb3Vjb3VcMQ==?=
X-XSS-Protection:1;mode=block
 
Can anyone tell me what am I doing wrong?
 
Many thanks

1 Answers
Best Answer
admin Staff answered 6 years ago

Hello,

I see that you’ve found the solution yourself, as I see here on SO, https://stackoverflow.com/questions/49163993/flutter-asp-net-web-api-invalid-header-field-name/49183924#49183924.

I’ll mark this as solved then. Thanks.