[英]How can I fix this DetailedApiRequestError(status: 404, message: No error details. HTTP status was: 404.)
anybody knows what I'm doing wrong, I keep getting this error任何人都知道我做错了什么,我一直收到这个错误
DetailedApiRequestError(status: 404, message: No error details. HTTP status was: 404.)
Here's my code.这是我的代码。
final _credentials = new ServiceAccountCredentials.fromJson(r'''
{
"private_key_id": "4XXXXXxXXXXXXXXXXXXXXXXXXXXXXXXXXXXx",
"private_key": ".....==\n-----END PRIVATE KEY-----\n",
"client_email": "xxxxxxx@----.com",
"client_id": "11XXXXXXXXXXXXXX4",
"type": "service_account"
}
''');
clientViaServiceAccount(_credentials, _SCOPES).then((http_client) {
var pubSubClient = new PubsubApi(http_client);
var messages = {
'messages': [
{
'data': base64Encode(utf8.encode('{"foo": "bar"}')),
},
]
};
pubSubClient.projects.topics
.publish(new PublishRequest.fromJson(messages), "your-topic")
.then((publishResponse) {
debugPrint(publishResponse.toString());
}).catchError((e,m){
debugPrint(e.toString());
});
});
I have a stateful widget with this code in initState()
, when I run it I get the error above.我在
initState()
中有一个带有此代码的有状态小部件,当我运行它时,我收到上面的错误。 when I check my google cloud nothing is published.当我检查我的谷歌云时,没有发布任何内容。 Anyone who can help me quickly.
任何可以快速帮助我的人。
So this here a solution, change this:所以这是一个解决方案,改变这个:
pubSubClient.projects.topics
.publish(new PublishRequest.fromJson(messages), "your-topic")
.then((publishResponse) {
debugPrint(publishResponse.toString());
}).catchError((e,m){
print(m.toString());
debugPrint(e.toString());
});
to this:对此:
pubSubClient.projects.topics
.publish(new PublishRequest.fromJson(messages), "projects/projectIDXX/topics/yourTopic")
.then((publishResponse) {
debugPrint(publishResponse.toString());
}).catchError((e,m){
print(m.toString());
debugPrint(e.toString());
});
The issue was with topic.问题与主题有关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.