在向geoserver rest api发出帖子请求时,我得到了一个与JSON相关的错误。 api的文档是http://docs.geoserver.org/api/#/1.0.0/featuretypes.yaml。我发布的帖子请求是
handler: function(request, reply) {
var layerDef = JSON.stringify({
"namespace": {
"name": "u77211780_55d2_11e7_96bc_d1171b78c7a0",
"href": "http://192.168.0.30:8080/geoserver/rest/workspaces/wfsresult/datastores/WFSSourceResult/featuretypes/u77211780_55d2_11e7_96bc_d1171b78c7a0.json"
}
});
Request('http://192.168.0.30:8080/geoserver/rest/workspaces/wfsresult/datastores/WFSSourceResult/featuretypes.json',{
method: 'POST',
auth: auth,
headers: {
'content-type': 'application/json'
},
featureType: layerDef
})
.on('response', (err, response, body) => {
console.log(layerDef);
if(err) {
reply(err);
} else {
reply(body);
}
});
}
它会返回此问题:: org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 0 of
我认为我已经定义了正确的json并正确地将其字符串化。为什么要回归这个问题?