Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 节点服务器没有收到我发送给他的JSON文件_Python_Express - Fatal编程技术网

Python 节点服务器没有收到我发送给他的JSON文件

Python 节点服务器没有收到我发送给他的JSON文件,python,express,Python,Express,我正在尝试使用python向我的express服务器发送post请求,以下是我的代码: import requests print("started"); URL = "http://localhost:5000/api/chat" PARAMS = {'ID':"99","otherID":"87",'chat':[{"senderName":"tom","text":"helloworld"}]} r = requests.post(url = URL, data = PARAMS)

我正在尝试使用python向我的express服务器发送post请求,以下是我的代码:

import requests


print("started");
URL = "http://localhost:5000/api/chat"

PARAMS = {'ID':"99","otherID":"87",'chat':[{"senderName":"tom","text":"helloworld"}]}

r = requests.post(url = URL, data = PARAMS)

pastebin_url = r.text 
print("The pastebin URL is:%s"%pastebin_url) 
但是当我收到调用时,我在节点服务器上得到一个空对象,我是否遗漏了什么?
(对于postman,它可以正常工作,因此不是服务器)

通常,请求库根据用于发出请求的参数在请求类型上进行区分。这意味着,如果您打算发布一篇JSON文章,那么应该像这样使用
JSON
param:

response = requests.post(url=URL, json=PARAMS)
这样做的目的是设置附带的标题,这就是为什么当您的express服务器尝试解析它时,它返回为空