Tuesday, 22 December 2015

Adding existing style while publishing a new layer in GeoServer using REST API


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

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...