简体   繁体   English

API响应在Postman中返回0,但从C#调用时返回-0.0

[英]API response returns 0 in Postman, but -0.0 when calling from C#

I'm making a call to an API using C# code. 我正在使用C#代码调用API。

I have an API class that has a GET method. 我有一个具有GET方法的API类。 (I admit that I got the code from a colleague and have just adapted it). (我承认我从同事那里获得了代码,并且刚刚对其进行了修改)。

GET方法

The ProcessRequest method takes the response from the WebRequest and stores it in a variable called feed ProcessRequest方法从WebRequest获取响应并将其存储在一个名为feed的变量中

When I use the text visualizer to see what is coming back, then I see the item key-value pair has a -0.0 value. 当我使用文本可视化工具查看返回的内容时,然后看到item键值对具有-0.0值。

ProcessRequest方法 Visual Studio工具提示值

This unfortunately gives an error when I use Newtonsoft to deserialise into a class that I have defined as this field should be an integer. 不幸的是,当我使用Newtonsoft反序列化为我定义的类时,这会产生错误,因为此字段应为整数。 NOTE: THE ERROR NEWTONSOFT RETURNS IS IRRELEVANT TO ME AT THIS POINT 注意:在这一点上,错误NEWTONSOFT返回与我无关

When I call the API using Postman, this is the result I get back ... 当我使用Postman调用API时,这就是我得到的结果...

邮递员的回应

You can see that the last KVP returns an integer value, which is what is expected. 您可以看到last KVP返回一个整数值,这是预期值。

Does anyone have any idea of why I am getting a different response in my C# code than I am from Postman, and what I can do about it? 有谁知道为什么我在C#代码中得到的答复与从邮递员那里得到的答复有所不同,我能做什么?

Summary:- C# returns me a -0.0 in the value of that Key-Value pair Postman returns me a 0 in the value of that Key-Value pair 摘要:-C#向我返回该键值对值的-0.0,邮递员向我返回该键值对值的0。

I'm unable to post a working code sample that hits the API as the API is a pay-for service. 由于该API是一项付费服务​​,因此我无法发布有效的示例代码来访问该API。

Postman will prettify the result. 邮递员将美化结果。

Clicking the Raw button, shows the -0.0 value coming back from the API provider, just as the C# code hinted at. 单击Raw按钮,显示从API提供程序返回的-0.0值,正如C#代码所提示的那样。

邮递员原始回复

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

相关问题 gandi api 从 C# 调用返回 400。它的工作正常从 Postman - gandi api call from C# returns 400. Its Working Fine from Postman 在 C# Web API 中,当我在 Postman 中发布多个数据时,它返回“null”值 - In C# Web API, when I POST multiple data in the Postman it returns 'null' value Post Rest Web API在Postman上工作,但未从C#项目中的代码返回任何响应 - Post rest web api working from Postman but not returning any response from code in C# project 通过Webrequest调用时,Api返回403错误,但在邮递员中调用时有效 - Api returns 403 error when calling through webrequest, but works when calling in postman 从 Postman 调用简单的 C# Web 服务方法时出现问题 - Problem calling a simple C# Webservice method from Postman 从 C# 调用图形 API 时出现 NotAcceptable 错误 - NotAcceptable error when calling graph API from C# 从 C# 调用 AirBnb api 时出现 403 - 403 when calling AirBnb api from C# 使用Postman从API检索的数据与使用C#程序时不同 - Data retrieved from API using Postman different than when using C# program 为什么返回C#Convert.ToDouble(5/100)0.0而不是0.05 - Why returns C# Convert.ToDouble(5/100) 0.0 and not 0.05 在C#Web API中调用POST方法时的406 HTTP响应 - 406 HTTP Response when calling POST method in C# Web API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM