I am using the following OpenApi Tool from Github: OpenApi-generator It automatically generates classes based on a YAML file. I integrated these classes in my Flutter project and want to use these. I want to use a Method, which makes an Api call to an WebServer called Agent.Workbench.
This was in the README.md generated by the Tool:
final api_instance = AdminsApi();
try {
final result = api_instance.infoGet();
print(result);
} catch (e) {
print('Exception when calling AdminsApi->infoGet: $e\n');
}
## Documentation for API Endpoints
All URIs are relative to *https://localhost:8080/api*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AdminsApi* | [**infoGet**](doc//AdminsApi.md#infoget) | **GET** /info | Returns system information
*AdminsApi* | [**loadGet**](doc//AdminsApi.md#loadget) | **GET** /load | Returns the current System load
*AdminsApi* | [**stateGet**](doc//AdminsApi.md#stateget) | **GET** /state | Returns the current AWB state
But I get following Error:
Error on line 1, column 17: Invalid media type: expected no more input.
╷
1 │ application/json, application/json; charset=utf-8
I checked the Webserver it does await a application/json and the Client (my Code) too.
This is my Code:
Future<void> _testCall() async {
final api_instance = AdminsApi();
try {
final result = api_instance.infoGet();
print(result);
} catch (e) {
print('Exception when calling AdminsApi->infoGet: $e\n');
}
}
This should print my system information in the Terminal in VSCode.
This exception is thrown because the string
application/json, application/json; charset=utf-8is not a valid media type as defined in RFC 7231.You can reproduce this error by calling
Instead it should be
As you are using a code-generation framework, we would need to see your input yaml file to see what exactly causes the bad code generation.