WSO2DSS - JSON 格式的 REST POST 操作调用:异常
WSO2DSS - REST POST operation call in JSON format : exception
按照下面的说明在 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 文档提供的说明进行操作即可。
似乎参数传递不正确(例如:articleTitle 已变为空,但在数据库中 table 您已将其定义为非空列)。 article-payload.json 文件应位于您尝试使用 curl 调用请求的目录中(即在 D:\testing\curl-7.46.0-win64\bin 内)
按照下面的说明在 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 文档提供的说明进行操作即可。
似乎参数传递不正确(例如:articleTitle 已变为空,但在数据库中 table 您已将其定义为非空列)。 article-payload.json 文件应位于您尝试使用 curl 调用请求的目录中(即在 D:\testing\curl-7.46.0-win64\bin 内)