Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.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
curl-get-json返回404_Json_Curl - Fatal编程技术网

curl-get-json返回404

curl-get-json返回404,json,curl,Json,Curl,我正在本地主机上运行一个带有REST服务的tomcat服务器 在浏览器中键入的这个url给了我一个json响应:http://localhost:8080/a/rest/dataset/list 但是当我使用curl时:curlhttp://localhost:8080/a/rest/dataset/list响应是HTML代码,服务器发出404错误 curl命令中缺少什么?Tomcat可能正在等待用户发出的特殊格式的HTTP请求。由于您希望在json中得到响应,您可能应该将以下参数转发给curl

我正在本地主机上运行一个带有REST服务的tomcat服务器

在浏览器中键入的这个url给了我一个json响应:
http://localhost:8080/a/rest/dataset/list

但是当我使用curl时:
curlhttp://localhost:8080/a/rest/dataset/list
响应是HTML代码,服务器发出404错误


curl命令中缺少什么?

Tomcat
可能正在等待用户发出的特殊格式的HTTP请求。由于您希望在
json
中得到响应,您可能应该将以下参数转发给curl:

-H 'Content-Type: application/json'

此外,您可以始终将期望他返回的响应指定给任何HTTP服务器。许多基于HTTP的后端应用程序都会在给定HTTP请求的情况下发出响应

服务器端是否有任何预期的HTTP参数/Cookie?嗨,Halim,没有。doh,在盯着屏幕看了一个小时后:这实际上是服务路径中的一个输入错误。服务器名是正确的,所以它得到了一些东西,但没有返回json。谢谢你,哈利姆。。。