DioError [DioErrorType.RESPONSE]: Http status error [400]
1) check if the request parameter is correct:
, for example, if the parameter value in the map is an array, the following code in the innerParticipateGroups span> and innerParticipators span> the value of the value can’t into the toString, otherwise it will be submitted to the 400 p>
Map<String,dynamic> params = {
"chamberId":resultId,
"description":remark,
"finishAt":1564979400000,
"innerParticipateGroups":[],
"innerParticipators":[],
"name":meetingName,
"reportId":"",
"scheduleId":"",
"startAt":1564975800000
};
2) if above is correct, check the receive mode of parameters when get and post are called
see Dio(v2.1.0) GET request source code:
Future<Response<T>> get<T>(
String path, {
Map<String, dynamic> queryParameters,
Options options,
CancelToken cancelToken,
ProgressCallback onReceiveProgress,
}) {
return request<T>(
path,
queryParameters: queryParameters,
options: _checkOptions("GET", options),
onReceiveProgress: onReceiveProgress,
cancelToken: cancelToken,
);
}
queryParameters queryParameters
response = await dio.get(url, queryParameters: params);
POST source:
/// Handy method to make http POST request, which is a alias of [Dio.request].
Future<Response<T>> post<T>(
String path, {
data,
Map<String, dynamic> queryParameters,
Options options,
CancelToken cancelToken,
ProgressCallback onSendProgress,
ProgressCallback onReceiveProgress,
}) {
return request<T>(
path,
data: data,
options: _checkOptions("POST", options),
queryParameters: queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
}
POST parameters data queryParameters; queryParameters; 400; queryParameters;
response = await dio.post(url, data : params);
DioError [dioerrortype.response]: Http status error [500]
Check if the header is set or set incorrectly
HttpGo() {
dio = Dio(BaseOptions(
baseUrl: 'https://www.***.com/',
headers: getHeaders(),
connectTimeout: 5000,
receiveTimeout: 3000,
));
}
getHeaders () {
return {
'Accept':'application/json, text/plain, */*',
'Content-Type':'application/json',
'Authorization':"**",
'User-Aagent':"4.1.0;android;6.0.1;default;A001",
"HZUID":"2",
};
}
DioError [dioerrortype.response]: Http status error [415]
change the request parameter data format FormData to Map< String,dynamic> Try p>
if you think it will work for you, please click “like” to support it ~ thanks ~
p>
Read More:
- Spring MVC error HTTP status 400 – bad request
- request:fail url not in domain list or Cannot send network request to localhost
- The request failed with HTTP status 401: Unauthorized. SSRS 2008
- Realization of breakpoint download based on DIO in flutter
- Springboot project: error parsing HTTP request header note: further occurrences of HTTP request parsing
- React Native: TypeError: Network request failed
- IIS “Bad Request – Request Too Long. HTTP Error 400. The size of the request headers is too long.”
- React Native Network Request Failed solution
- urlopen error unknown url type:httpë/HTTP Error 400:Bad Request
- Bad Request – Request Too Long. HTTP Error 400. The size of the request headers is too long
- TypeError:Network request failed
- Browser prompt: Source mapping error: request failed with status 404 Source URL: http://xxx.js Source mapping URL: jquery.min.map
- Error parsing HTTP request header Note: further occurrences of HTTP header p
- HTTP 400 error – bad request
- Error: request failed with status code 500
- Provider: SQL network interfaces, error: 25 http://www.itsvse.com/thre
- Error in v-on handler (Promise/async): “Error: Request failed with status code 500“
- HTTP 405 Error: Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
- ajax error 400 (Failed to load resource: the server responded with a status of 400 (Bad Request))
- The media could not be loaded, either because the server or network failed or because the format is