Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/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
从php将json发布到REST_Rest_Http Post_Dropwizard - Fatal编程技术网

从php将json发布到REST

从php将json发布到REST,rest,http-post,dropwizard,Rest,Http Post,Dropwizard,我有一个RESTURL(使用DropWizard用Java编码),我想从PHP发布一个json。但是,我得到了415不支持的MediaType错误。我查阅了许多论坛,但我无法找出可能的错误。我的两端代码如下: 服务器 @POST @路径(“/updatetable”) @定时 公共表UpdateResponse updateTable(TestClass testObj){ LOG.info(“内部可更新函数”); //其他代码。。。 } 客户端 TestClass 公共类TestClas

我有一个RESTURL(使用DropWizard用Java编码),我想从PHP发布一个json。但是,我得到了
415不支持的MediaType
错误。我查阅了许多论坛,但我无法找出可能的错误。我的两端代码如下:

服务器

@POST
@路径(“/updatetable”)
@定时
公共表UpdateResponse updateTable(TestClass testObj){
LOG.info(“内部可更新函数”);
//其他代码。。。
}
客户端


TestClass

公共类TestClass{
私有字符串testString;
公共TestClass(字符串testString){
超级();
this.testString=testString;
}
公共测试类(){
超级();
}
公共字符串getTestString(){
返回testString;
}
公共void setTestString(String testString){
this.testString=testString;
}
}

请求未到达REST(未打印日志行)。这里缺少什么?

尝试将应用程序/json内容类型更改为以下类型之一

application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json

尽管RFC中正确指定的是application/json,但java代码可能有问题

添加注释
@Consumes(MediaType.application\u json)

我想问题出在PHP代码上,因为我尝试了terminal中的curl命令,它可以工作。