dart-dio-next: DioError [DioErrorType.other]: FormatException: Invalid HTTP header field value
See original GitHub issue[dart-dio-next] Error on setting header object
Description
Header json objects are allowed. I am trying to send in a header object that’s defined in the openapi spec. Here’s the api side.
createRegistrationCode:
get:
summary: Get a registration code for adding a new player
operationId: createRegistrationCode
parameters:
- in: header
name: tracer
schema:
$ref: '../common/models/tracer.yaml#/Tracer'
responses:
'200': ...
I am generating the dart-dio-next client and setting the object without any complaints. However, when I run it, I get the following error. That’s the complete object I am sending. Note that the '\n’s are pasted as is - that’s not my intervention.
flutter: DioError [DioErrorType.other]: FormatException: Invalid HTTP header field value: "Tracer {\n tracerId=TracerId {\n userId=_user_,\n timestamp=1640694471654,\n sequence=1,\n deviceInstanceId=Wiyhnm,\n },\n taskName=RegistrationCubit: Fetching data,\n traces=[Trace {\n timestamp=1640694471654,\n subTaskName=RegistrationCubit: Fetching data,\n message=,\n traceState=start,\n }, Trace {\n timestamp=1640694471656,\n subTaskName=CreateRegistrationCodeRepoImpl: createRegistrationCode,\n message=,\n traceState=start,\n }],\n metrics=[],\n deviceDetails=DeviceDetails {\n installationType=web,\n deviceInfo=,\n },\n}" (at character 9)
Tracer {
^
openapi-generator version
latest generator - 5.3.0
Let me know what I can do. Thanks.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Invalid HTTP header field value in flutter - Stack Overflow
I receive this error Unhandled Exception: FormatException: Invalid HTTP header field when my header value contain accent: village_name=moapé ...
Read more >FormatException Invalid HTTP header Flutter on iOS-Flutter
According to RFC 2616, HTTP headers must only include characters in ISO-8859-1, unless they are encoded in a MIME format, which might look...
Read more >Invalid HTTP header field value in flutter - Zeste de Savoir
Lorsque j'ajoute les cookies dans le header j'obtiens cette erreur Unhandled Exception: FormatException: Invalid HTTP header field.
Read more >Invalid HTTP header field value in flutter - Anycodings.com
I create a function use anycodings_flutter uri.encodecomponent to solve my problem anycodings_flutter this my code: convert(value){ ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you want to transmit objects as headers, you probably need an opinionated serialization mechanism on client and server. This is nothing we can provide out of the box.
Hi @kuhnroyal it looks like headers are supposed to be strings. Even if I make custom objects out of it in my openAPI specs, the web server implementations with RestEasy complain on it. The error “Invalid HTTP header field value” is right. I guess the OpenAPI specs definition should not be saying that headers can be custom objects. I’m closing this error. Thanks for looking into it.