type'_internallinkedHashmap< string,string>'不是类型的子类型' string'在类型中
我试着在strapi中向我的API发布一张笔记,但我有错误 [错误:flutter/lib/ui/ui_dart_state.cc(209)]未经手的例外:键入'_internallinkedhashmap< string,string>'不是类型铸件中的“字符串”类型的子类型
,它是我的
Map<String, String> header = {
"Authorization": "Bearer ${sharedp!.getString('token')}"
};
addPosts() async {
var response = await http.post(
Uri.parse(post_note),
body: {
"data": {
"title": "upload api",
"content": "upload api to the user and show it in the app by id",
"userid": sharedp!.getString('id')
}
},
headers: header,
);
var responsebody = jsonDecode(response.body);
print(responsebody);
return responsebody;
}
代码
{
"data":{
"title":"upload api",
"content":"upload api to the user and show it in the app by id",
"userid":1
}
}
I am try to post an note to my API in Strapi but I have that error
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type '_InternalLinkedHashMap<String, String>' is not a subtype of type 'String' in type cast
that is my code
Map<String, String> header = {
"Authorization": "Bearer ${sharedp!.getString('token')}"
};
addPosts() async {
var response = await http.post(
Uri.parse(post_note),
body: {
"data": {
"title": "upload api",
"content": "upload api to the user and show it in the app by id",
"userid": sharedp!.getString('id')
}
},
headers: header,
);
var responsebody = jsonDecode(response.body);
print(responsebody);
return responsebody;
}
then that how I make post in postman
{
"data":{
"title":"upload api",
"content":"upload api to the user and show it in the app by id",
"userid":1
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将JSON包装在模型类中,并通过执行以下操作获得您想要的内容,
现在,一旦您构建了ApireQuest模态对象,
请确保这会有所帮助。
You can just wrap the json in a model class and obtain what you want by doing the following,
Now once you construct your ApiRequest modal object like following,
Pretty sure this helps..