geoserver

How in GeoServer REST API to send POST request to add a polygon shape in GeoJSON format?


I am using React, Leaflet Draw and GeoServer. The map already has shapes in GeoJSON format that I get from GeoServer. I have drawn a polygon on the map and now I have an object like this

{
  "type": "FeatureCollection",
  "features": [
      {
          "type": "Feature",
          "properties": {},
          "geometry": {
              "type": "Polygon",
              "coordinates": [
                  [
                      [
                          1528915.8154546698, 6627851.731194374
                      ],
                      [
                          1528923.3154546698, 6627859.231194374 
                      ],
                      [
                          1528923.3154546698, 6627851.731194374 
                      ],
                      [
                          1528915.8154546698, 6627851.731194374
                      ]
                  ]
              ]
          }
      }
  ]
}

Now I need to send it to GeoServer using the REST API. But I can't find a suitable endpoint for this in their swagger - https://docs.geoserver.org/stable/en/user/rest/index.html#rest

How can I do this?

I've tried to figure it out in the GeoServer documentation


Solution

  • You can't! The REST API is the management of the GeoServer system not interacting with the data within the server. For transactional changes you need to use the WFS API or if you are wedded to JSON then you can use the new v3 WFS which is a community extension at present.