简体   繁体   English

邮递员API无效的内容类型标题

[英]Postman API Invalid Content-Type Header

I'm trying to test and API call for the Smartsheet API in Postman, but I keep receiving the same error. 我正在尝试在Postman中测试和对Smartsheet API进行API调用,但是我一直收到相同的错误。 Even though I am defining the correct Content-Type as per the API documentation, the response I get is the error 1124 , which is an invalid content-type header . 即使我按照API文档定义了正确的Content-Type,我得到的响应仍然是错误1124 ,它是无效的content-type标头 I haven't been able to figure out exactly what is causing the issue. 我一直无法弄清楚到底是什么引起了问题。 I have tried typing the header in the address and in the header tab in Postman, but neither option has given me the result I wanted. 我已经尝试在邮递员的地址和标题选项卡中键入标题,但是这两个选项都没有给我想要的结果。

Postman Screenshot 邮递员截图

在此处输入图片说明

If I run the same request in Postman as your screenshot shows (except using my sheet ID), with the same headers that you're using, my request succeeds. 如果我在Postman中运行与您的屏幕快照所示相同的请求(使用我的工作表ID除外),并且使用的标题相同,则我的请求成功。 ie, if you're sending the Content-Type header with value application/json for this request, you should not be receiving the error message that you're reporting (1124 - invalid content-type header). 即,如果您要为此请求发送带有值application / jsonContent-Type标头,则不应收到正在报告的错误消息(1124-无效的content-type标头)。

You would, however, receive that error message if you were either not including the Content-Type header at all OR if you were specifying an invalid value for the Content-Type header. 但是,如果您根本不包括Content-Type标头,或者为Content-Type标头指定了无效的值,则会收到该错误消息。 A suggestion for troubleshooting: use Fiddler (or a similar tool) to examine the request that's being sent over the wire when you execute this request in Postman -- does it include the Content-Type header, and if so, what's the value of that header? 解决问题的建议:当您在Postman中执行此请求时,使用Fiddler (或类似工具)检查通过网络发送的请求-它是否包含Content-Type标头,如果有的话,它的价值是什么标头?

UPDATE: 更新:

Thanks for adding a screenshot of the body you're setting in Postman -- I believe that's the source of your issue. 感谢您添加您在Postman中设置的正文的屏幕截图-我相信这就是问题的根源。 ie, your Content-Type header says that the request body is in JSON format, but you're actually not sending JSON. 也就是说,您的Content-Type标头说请求主体为JSON格式,但实际上您不是在发送JSON。 To fix this: instead of specifying key/value pairs in Postman, select the raw radio button and specify the body in JSON format. 要解决此问题:请选择原始的单选按钮,然后以JSON格式指定正文,而不是在Postman中指定键/值对。 Here's a screenshot of what that looks like: 这是看起来的屏幕截图:

在此处输入图片说明

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

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