I have a function which publishes a layer in GeoServer with the REST API. Now I want to add an existing style in the layer while publishing it.
Anyone has any idea where I write the style name or call the 'style.sld' while publish the layer?
const publish = function (layerName) {
return new Promise((resolve, reject) => {
axios({
method: 'POST',
url: `http://${GEOSERVER_IP}:${GEOSERVER_PORT}/geoserver/rest/workspaces/workspaceName/datastores/datastoreName/featuretypes.xml`,
auth: {
username: `${GEOSERVER_ADMIN_USER}`,
password: `${GEOSERVER_ADMIN_PASS}`
},
headers: {
'Content-Type': 'text/xml'
},
data: `
${layerName}
EPSG:4326
`
})
.then(response => {
resolve({
ok: 1,
message: `Layer has been published.`
})
})
.catch(err => {
reject({
ok: 0,
message: err.response.data,
})
})
})
}
No comments:
Post a Comment