我正在尝试将图像从 Web API 返回到 zebble,如下所示:
网页接口:
public HttpResponseMessage GetImage()
{
var memoryStream = custom logic to create image
var result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(memoryStream.ToArray());
result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
return result;
}
斑块:
var imageData = await Get<byte[]>(url);
var imageView = new ImageView { ImageData = imageData }
但是Get
抛出异常:
Exception thrown: 'Newtonsoft.Json.JsonReaderException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonReaderException' in Newtonsoft.Json.dll
Exception thrown: 'System.Exception' in Zebble.UWP.dll
Exception thrown: 'System.Exception' in mscorlib.ni.dll
ERROR: HttpGet -> 'url' failed.
WARNING: Failed to convert API response to Byte[]
###############################################
Base issue: Unexpected character encountered while parsing value: �. Path '', line 1, position 1.
--------------------------------------
STACK TRACE:
at Zebble.Framework.BaseApi.<GetFromTheServer>d__24`1.MoveNext()
at Zebble.Framework.BaseApi.<Get>d__25`1.MoveNext()
知道如何解决这个问题吗?