无法使用浏览器访问Web API(XML错误) [英] Unable to access to Web API with browser (XML error)

查看:213
本文介绍了无法使用浏览器访问Web API(XML错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Good evening,

最近,我使用Azure Function App + Cosmos DB制作了一个简单的Web API.到目前为止,它运行良好(我用Postman击中了端点,一切都很好).但是,现在我正尝试使用浏览器https://.azurewebsites.net/api/assets直接访问Web API 我发现此错误阻止我访问该页面:

Recently I have made a simple Web API with Azure Function App + Cosmos DB. So far it worked perfectly (I used Postman to hit the endpoints and everything went fine). However, now I'm trying to access directly to the Web API with the browser https://.azurewebsites.net/api/assets and I found this error that impedes me to access to the page:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<ApiErrorModel xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Azure.WebJobs.Script.WebHost.Models">
<Arguments xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true"/>
<ErrorCode>0</ErrorCode>
<ErrorDetails i:nil="true"/>
<Id>c24a8819-b80f-4da9-a3d8-a3f8d3e3ca7c</Id>
<Message>
An error has occurred. For more information, please check the logs for error ID c24a8819-b80f-4da9-a3d8-a3f8d3e3ca7c
</Message>
<RequestId>4b6bb834-32e7-4ff8-8b01-a9471311cdd1</RequestId>
<StatusCode>InternalServerError</StatusCode>
</ApiErrorModel>

我试图在Function App的监视器中检查错误ID.但是,我找不到对应的ID(也许是因为它不是运行应用程序本身的问题,而是可以访问它). 您知道如何解决此问题吗?,请记住,我正在使用Azure Microsoft的Function App

I tried to check the error ID in the monitor of Function App. However, I can't find the corresponding ID (maybe because it's not a problem of running the application itself, but to access into it). Do you know how can I fix this problem?, bear in mind that I'm using the Function App from Azure Microsoft

预先感谢!

推荐答案

使用来自Function App Azure的日志流,我找到了以下信息:

Using the log streaming from Function App Azure, I found this info: 

<div class="content-container"> 
<fieldset><h4>More Information:</h4> 
This error means that there was a problem while processing the request. The request was received by the Web server, but during processing a fatal error occurred, causing the 500 error. 
<p><a href="http://go.microsoft.com/fwlink/?LinkID=62293&amp;IIS70Error=500,0,0x00000000,14393">View more information &raquo;</a></p> 
<p>Microsoft Knowledge Base Articles:</p> 
  


这:

2018-07-12T18:43:20.166 [Info] Host lock lease acquired by instance ID '6d88415e00f499dd2c39b2637fc37619'.
2018-07-12T18:43:20.397 [Info,assets] Executing 'Functions.assets' (Reason='This function was programmatically called via the host APIs.', Id=378526d1-6cfe-40f9-aa28-0dd8722eed1f)
2018-07-12T18:43:20.412 [Info,assets] Function completed (Success, Id=378526d1-6cfe-40f9-aa28-0dd8722eed1f, Duration=561ms)
2018-07-12T18:43:20.412 [Info,assets] Executed 'Functions.assets' (Succeeded, Id=378526d1-6cfe-40f9-aa28-0dd8722eed1f)
2018-07-12T18:43:20.444 [Error] {"id":"0fe39e31-14b4-449b-ba40-3cad1dd0a8dd","requestId":"d4c3af72-a2a6-45fe-aeb2-524552986c29","statusCode":500,"errorCode":0,"message":"An error has occurred. For more information, please check the logs for error ID 0fe39e31-14b4-449b-ba40-3cad1dd0a8dd"}
2018-07-12T18:43:20.444 [Error] System.Runtime.Serialization.InvalidDataContractException : Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.

但是,我仍然不知道该怎么做...我的应用程序功能代码非常简单,我还没有实现任何奇怪的东西.只是想从JSON文件中检索数据:

However, I still don't know what to do... My app function code is really simple, I haven't implemented anything odd. Just wanted to retrieve data from a JSON file:

using System.Net;

public static HttpResponseMessage Run(HttpRequestMessage req, TraceWriter log, IEnumerable<dynamic> assets)
{

   return req.CreateResponse(HttpStatusCode.OK, assets);
}



这篇关于无法使用浏览器访问Web API(XML错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆