简体   繁体   English

Web API返回JSON错误,但Visual Studio仅将其视为状态码500

[英]web api returns a json error but visual studio only sees it as status code 500

I'm getting a 500 status code back in visual studio for an api shown below although when using PostMan with the same credentials I get a json response back saying the token has expired. 我在Visual Studio中获取了如下所示api的500状态代码,尽管使用具有相同凭据的PostMan时,我得到了一个json响应,说令牌已过期。 Is this because I'm not seeing the response back as json or something? 这是因为我没有看到响应返回为json之类的东西吗? Obviously I need to handle if the token has expired so getting 500 back is not sufficient. 显然,我需要处理令牌是否已过期,因此取回500还不够。 Many thanks, 非常感谢,

Code failing with status code 500 代码失败,状态码为500

在此处输入图片说明

Same call but using PostMan 相同的通话,但使用PostMan

在此处输入图片说明

使用WebException而不是Exception。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM