Api geoserver上载kml无格式

Api geoserver上载kml无格式,api,geoserver,Api,Geoserver,我正在使用geoserver()的API,使用post请求将一个新的kml文件上传到mu本地机器,并使用以下json { "import": { "targetWorkspace": { "workspace": { "name": "sample" } }, "targetStore": { "dataStore": { "name": "sample

我正在使用geoserver()的API,使用post请求将一个新的kml文件上传到mu本地机器,并使用以下json

{
   "import": {
      "targetWorkspace": {
         "workspace": {
            "name": "sample"
         }
      },
      "targetStore": {
         "dataStore": {
            "name": "sample"
         }
      },
      "data": {
        "type": "file",
        "file": "/data/sample_dir/sample.kml"
      }
   }
}
根据API文档,我应该在响应中获得数据类型和状态,但我得到的是挂起的文件格式,没有文件格式。 答复:

{
    "import": {
        "id": 23,
        "href": "http://localhost:8080/geoserver/rest/imports/23",
        "state": "PENDING",
        "archive": false,
        "targetWorkspace": {
            "workspace": {
                "name": "sample"
            }
        },
        "targetStore": {
            "dataStore": {
                "name": "sample",
                "type": "Directory of spatial files (shapefiles)"
            }
        },
        "data": {
            "type": "file",
            "format": null,
            "file": "sample.kml"
        },
        "tasks": []
    }
}

显然,geoserver不接受API文档中所述的相对路径。 如果不是:

"data": {
        "type": "file",
        "file": "./data/sample_dir/sample.kml"
      }
我用

"data": {
        "type": "file",
        "file": "/var/lib/tomcat7/webapps/geoserver/data/sample_dir/sample.kml"
      }

根据请求,它可以正常工作。

因为您的文件以
/
开头,所以它不是相对的!你能给我看看你用来上传到GeoServer的代码吗?我很难让POST请求正确。