【发布时间】:2020-12-01 14:11:30
【问题描述】:
我即将向 googles API 创建一个请求,目的是更改 gmail 帐户的签名。
这是触发错误的请求部分。如果我将“签名”字符串更改为此“测试”,一切正常。我知道这一定与我似乎找不到问题的格式有关。
string signature = "<div>Med venlig hilsen / regards,</div><div><br></div><div><strong>" + "Name" + "</strong></div>" +
"<div><em>" + "Role" + "</em></div>" +
"<div><a href=\"www.xxx.com/da/\"style=\"color:rgb(17,85,204);\"target=\"_blank\"><strong>xxxx xxxxx</strong></a></div>" +
"<div>Tel. " + "Phone" + "</div>" +
"<div>E-mail: <a href=\"mailto:" + "Mail" + "\"style=\"color:rgb(17,85,204);\"target=\"_blank\">" + "Mail" + "</a></div>" +
"<div><a href =\"www.xxx.com/da/\"style=\"color:rgb(17,85,204);\"target=\"_blank\"><img src=\"www.xxx.com/wp-content/uploads/2018/09/xxxxx-logo-7.png\"></a></div>" +
"<br></br><div>xxx<br> Reg.no. xxx- <a href =\"www.xxx.com/\"style=\"color:rgb(17,85,204);\"target=\"_blank\">www.xxx.com</a></div>";
错误如下:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Expected , or } after key:value pair.\n\u003cdiv\u003eMed venlig hils\n^",
"errors": [
{
"message": "Invalid JSON payload received. Expected , or } after key:value pair.\n\u003cdiv\u003eMed venlig hils\n^",
"domain": "global",
"reason": "parseError"
}
],
"status": "INVALID_ARGUMENT"
}
}
提前致谢!
【问题讨论】:
-
意味着你想找出给定 Json 中的错误吗?
-
@Sh.Imran 这就是目标。
-
反斜杠
\` are the issue in your Json. With\` Json 无法正常工作。如果您可以删除它,那么它将起作用。 -
@Sh.Imran 非常感谢!在 C# 中,'\"' 用于在字符串中定义一个 '"',所以我没有将它包含在请求中。谢谢!