因此,我有一个具有值(“状态”:“开始”)的api,我想更改为:(“状态”:“完成”)。如果有人对Flutter中的http.put请求有想法,请随时提供帮助:)
API:
GET /api/task/29/
HTTP 200 OK
Allow: GET, POST, PUT, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
{
"id": 29,
"description": "Berlinmurens Fall",
"state": "started",
"assigned_users": [
{
"username": "hugo",
"fullname": "Hugo Johnsson"
}
],
"subtasks": []
}
JSON:
{"id":29,"description":"Berlinmurens Fall","state":"started","assigned_users":[{"username":"hugo","fullname":"Hugo Johnsson"}],"subtasks":[]}
放置请求:
putRequest() async {
String url = "--URL--";
final Map<String, dynamic> jsonDataaa = {
"state": "done"
};
var response = await http.put(
Uri.encodeFull(url),
headers: { "Accept" : "application/json"},
body: json.encode(jsonDataaa),
encoding: Encoding.getByName("utf-8"),
);
return response;
}
我要做什么:
final Map<String, dynamic> jsonDataaa = {
"id": 29,
"description": "Berlinmurens Fall",
"state": "done",
"assigned_users": [
{
"username": "hugo",
"fullname": "Hugo Johnsson"
}
],
"subtasks": []
};