GMail API Error: Path "{userId}/messages/send" misses a "userId" parameter. Is this a bug?
GMail API Error: Path "{userId}/messages/send" misses a "userId" parameter. Is this a bug?
我正在尝试通过 .NET API 从 Unity3D 脚本中为 GMail 发送电子邮件。不幸的是我遇到了一些麻烦。每当我在游戏中按下 "R" 键时,都会调用以下代码。
//MEMBERS INCLUDED AT TOP OF CLASS
//TextAsset credFile;
//static String AppName = "Redacted-Appname";
//
//List<string> Scopes = new List<string>() { "GMAIL_SEND" };
if (Input.GetKeyDown(KeyCode.R))
{
UserCredential emailerCredential;
//Create Credential
using (MemoryStream credStream = new MemoryStream(credFile.bytes))
{
string credPath = "token.json";
emailerCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(credStream).Secrets,
Scopes,
"myDoubleCheckedEmailAddress@redacted.com",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
}
//Create Service using credential
GmailService service = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = emailerCredential,
ApplicationName = AppName
});
//Create Mail Message
MailMessage message = new MailMessage(
"myDoubleCheckedEmailAddress@redacted.com",
"DoubleCheckedTOEmailAddress@redacted.com",
"Test Email Using GMail API",
"This is a test of the emergency llama system.");
//Create Gmail Message
Message emailmsg = new Message();
//ConvertMail Message to URL Encoded Base64 string and feed it into Gmail message
emailmsg.Raw = HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.ASCII.GetBytes(message.ToString())));
string userId = "myDoubleCheckedEmailAddress@redacted.com";
service.Users.Messages.Send(emailmsg, userId).Execute();
}
由于此代码,我最终遇到以下异常:
ArgumentException: Path "{userId}/messages/send" misses a "userId"
parameter UnityLoader.js:1043 Parameter name: {userId}/messages/send
UnityLoader.js:1043 at
Google.Apis.Requests.RequestBuilder.BuildRestPath () [0x00000] in
<00000000000000000000000000000000>:0 UnityLoader.js:1043 --- End of
stack trace from previous location where exception was thrown ---
UnityLoader.js:1043 at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x00000] in <00000000000000000000000000000000>:0
我认为请求构建器正在将 {userId} 构建到 REST 请求中,而不是插入实际的用户名。正在寻找对 confirm/deny 这方面有更多经验的人。这是一个错误,还是我做错了?
假设这是一个错误,我将在 GMail.Net API github 上 post 解决它:https://github.com/googleapis/google-api-dotnet-client/issues
我将此作为错误报告发布到 Google Github 并按原样记录在那里。然而,我被告知 Unity3D 不是受支持的平台,因此该问题的优先级较低。如果有人想解决这个问题,他们将不得不对 repo 进行分支。
我正在尝试通过 .NET API 从 Unity3D 脚本中为 GMail 发送电子邮件。不幸的是我遇到了一些麻烦。每当我在游戏中按下 "R" 键时,都会调用以下代码。
//MEMBERS INCLUDED AT TOP OF CLASS
//TextAsset credFile;
//static String AppName = "Redacted-Appname";
//
//List<string> Scopes = new List<string>() { "GMAIL_SEND" };
if (Input.GetKeyDown(KeyCode.R))
{
UserCredential emailerCredential;
//Create Credential
using (MemoryStream credStream = new MemoryStream(credFile.bytes))
{
string credPath = "token.json";
emailerCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(credStream).Secrets,
Scopes,
"myDoubleCheckedEmailAddress@redacted.com",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
}
//Create Service using credential
GmailService service = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = emailerCredential,
ApplicationName = AppName
});
//Create Mail Message
MailMessage message = new MailMessage(
"myDoubleCheckedEmailAddress@redacted.com",
"DoubleCheckedTOEmailAddress@redacted.com",
"Test Email Using GMail API",
"This is a test of the emergency llama system.");
//Create Gmail Message
Message emailmsg = new Message();
//ConvertMail Message to URL Encoded Base64 string and feed it into Gmail message
emailmsg.Raw = HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.ASCII.GetBytes(message.ToString())));
string userId = "myDoubleCheckedEmailAddress@redacted.com";
service.Users.Messages.Send(emailmsg, userId).Execute();
}
由于此代码,我最终遇到以下异常:
ArgumentException: Path "{userId}/messages/send" misses a "userId" parameter UnityLoader.js:1043 Parameter name: {userId}/messages/send UnityLoader.js:1043 at Google.Apis.Requests.RequestBuilder.BuildRestPath () [0x00000] in <00000000000000000000000000000000>:0 UnityLoader.js:1043 --- End of stack trace from previous location where exception was thrown --- UnityLoader.js:1043 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0
我认为请求构建器正在将 {userId} 构建到 REST 请求中,而不是插入实际的用户名。正在寻找对 confirm/deny 这方面有更多经验的人。这是一个错误,还是我做错了?
假设这是一个错误,我将在 GMail.Net API github 上 post 解决它:https://github.com/googleapis/google-api-dotnet-client/issues
我将此作为错误报告发布到 Google Github 并按原样记录在那里。然而,我被告知 Unity3D 不是受支持的平台,因此该问题的优先级较低。如果有人想解决这个问题,他们将不得不对 repo 进行分支。