WSO2DSS - JSON格式的REST POST操作调用:异常

时间:2018-02-22 02:04:49

标签: wso2 wso2dss

下面的说明在curl命令中发送json请求有效负载

https://docs.wso2.com/display/DSS351/JSON+Mapping+Sample

以下是curl命令:

D:\testing\curl-7.46.0-win64\bin>curl -X POST -H 'Accept: application/json'  -H 'Content-Type: application/json' --data "@article-payload.json" http://8.39.51.27:9763/services/KMTool/insertarticles

错误:

**Error: Getting below error:**
Warning: Couldn't read data from file "article-payload.json", this makes an
Warning: empty POST.
curl: (6) Could not resolve host: application
curl: (6) Could not resolve host: application
<axis2ns22:DataServiceFault xmlns:axis2ns22="http://ws.wso2.org/dataservice"><ax
is2ns22:current_params>{articleTitle=null, articlePath=null, articleContent=null
, articleDesc=null, categoryID=null}</axis2ns22:current_params><axis2ns22:source
_data_service><axis2ns22:data_service_name>KMTool</axis2ns22:data_service_name><
axis2ns22:description>N/A</axis2ns22:description><axis2ns22:location>\KMTool.dbs
</axis2ns22:location><axis2ns22:default_namespace>http://ws.wso2.org/dataservice
</axis2ns22:default_namespace></axis2ns22:source_data_service><axis2ns22:ds_code
>DATABASE_ERROR</axis2ns22:ds_code><axis2ns22:nested_exception>org.postgresql.ut
il.PSQLException: ERROR: null value in column "articleTitle" violates not-null c
onstraint
  Detail: Failing row contains (31, null, null, null, null, null).</axis2ns22:ne
sted_exception><axis2ns22:current_request_name>_postinsertarticles</axis2ns22:cu
rrent_request_name></axis2ns22:DataServiceFault>

我将文件保存在以下位置:

C:\Users\testUser\Downloads\wso2dss-3.5.1\repository\deployment\server\dataservices\article-payload.json

不确定是什么原因造成的。只需按照wso2dss文档提供的说明进行操作。

1 个答案:

答案 0 :(得分:0)

似乎参数未正确传递(例如:articleTitle已变为null,但在数据库表中,您已将其定义为非空列)。 article-payload.json文件应该位于您尝试使用curl调用请求的目录中(即在D:\ testing \ curl-7.46.0-win64 \ bin中)