C# 4.0 .NET-来自Google Mirror API的Wierd响应
当我尝试使用Google的.NETAPI发布到镜像API时,我遇到了以下错误 Message Google.API.Requests.RequestError\r\n所需[400]\r\n错误[\r\n\tMessage[Required]位置[-]原因[Required]域[global]\r\n]\r\n字符串 我正在编写的程序作为plugin.dll从父.Net程序加载。当我将代码作为独立程序运行时,我没有看到此错误。我想知道是否有其他人可能遇到过类似的情况,或者可以指导我看什么? 我使用的代码取自谷歌镜像示例代码:C# 4.0 .NET-来自Google Mirror API的Wierd响应,c#-4.0,google-glass,google-mirror-api,C# 4.0,Google Glass,Google Mirror Api,当我尝试使用Google的.NETAPI发布到镜像API时,我遇到了以下错误 Message Google.API.Requests.RequestError\r\n所需[400]\r\n错误[\r\n\tMessage[Required]位置[-]原因[Required]域[global]\r\n]\r\n字符串 我正在编写的程序作为plugin.dll从父.Net程序加载。当我将代码作为独立程序运行时,我没有看到此错误。我想知道是否有其他人可能遇到过类似的情况,或者可以指导我看什么? 我使
public static TimelineItem InsertTimelineItem(
String text, String contentType, Stream attachment,
String notificationLevel)
{
TimelineItem timelineItem = new TimelineItem();
timelineItem.Title = text;
timelineItem.Text = text;
if (!String.IsNullOrEmpty(notificationLevel))
{
timelineItem.Notification = new NotificationConfig()
{
Level = notificationLevel
};
}
try
{
if (!String.IsNullOrEmpty(contentType) && attachment != null)
{
// Insert both metadata and media.
TimelineResource.InsertMediaUpload request = mirrorService.Timeline.Insert(
timelineItem, attachment, contentType);
request.Upload();
return request.ResponseBody;
}
else
{
HttpRequestMessage req= mirrorService.Timeline.Insert(timelineItem).CreateRequest();
string content = req.Content.ReadAsStringAsync().Result;
bool? pretty=mirrorService.Timeline.Insert(timelineItem).PrettyPrint;
// Insert both metadata and media.
return mirrorService.Timeline.Insert(timelineItem).Execute();
}
}
catch (Exception e)
{
Console.WriteLine("An error occurred: " + e.Message);
return null;
}
}
在最终返回mirrorService.Timeline.Insert语句时引发异常。我重新编译了Google Mirror API,以使用不同版本的Newtonsoft.JSON。这就解决了问题。 父程序使用的是不同版本的Newtonsoft.JSON,因此重新编译针对该版本的代码已修复该问题
Google.api.Mirror.v1的源代码可以从提供您的代码的网站下载。如果您的代码有问题,没有它,您希望我们如何帮助您?很抱歉。用代码更新了问题。