3

I'm using geoserver 2.13.1 with postgres 9.5 and postgis 2.4.2.

I am trying to use REST api to create workspace (works) and in it a datastore of postgis type. I have already prepared a template database in postgres and trying to use it here (this is the xml body of the post request to /geoserver/rest/workspaces/workspace_name/datastores):

<dataStore>
  <name>datastore_name</name>
  <description>dummy description</description>
  <type>PostGIS</type>
  <enabled>true</enabled>
  <connectionParameters>
    <entry key="Estimated extends">false</entry>
    <entry key="schema">venue</entry>
    <entry key="fetch size">1000</entry>
    <entry key="Max open prepared statements">50</entry>
    <entry key="Connection timeout">20</entry>
    <entry key="preparedStatements">false</entry>
    <entry key="database">mydbname</entry>
    <entry key="port">5432</entry>
    <entry key="min connections">1</entry>
    <entry key="dbtype">postgis</entry>
    <entry key="Loose bbox">true</entry>
    <entry key="host">localhost</entry>
    <entry key="max connections">10</entry>
    <entry key="user">foo</entry>
    <entry key="passwd">bar</entry>
    <entry key="create database">true</entry>
    <entry key="create database params">WITH TEMPLATE=mydbtemplate</entry>
  </connectionParameters>
  <__default>true</__default>
</dataStore>

The geoserver datastore is created as expected (and I'm getting 201 http code back), but the database itself is not created. No error messages. Only if I open that store now via geoserver web interface and click on the save button (without changing anything), only then is the database really created using desired template. So, all those params are correct, but there is something missing on the server side, like a commit or something, that would trigger the create db job.

I have tried:

  • sending /reset and /reload requests afterwards - no db created
  • changing workspace and datastore properties with put request to trigger datastore saving somehow - changes are accepted, but no db created
  • I even tried sql injection by putting commit in that create database params entry after "with template" statement - also no error and no db created

I don't see any other REST API function looking even remotely related to "apply changes". So, how can I achieve that via REST API?

  • Could anybody please tell me if posting of this issue to geoserver users mailinglist is considered as cross-posting? – TonyAngelino Jul 2 '18 at 13:41
0

You can perform several operation on workspaces. Please check the link https://docs.geoserver.org/latest/en/api/#/latest/en/api/1.0.0/workspaces.yaml

New contributor
Rajat Upadhyay is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Please refrain from posting link-only answers, since links may change and become dead ends. Rather extract relevant information and only add the link as reference. – Erik 2 days ago
0

You should do an operation that forces the datastore to be actually created and do something against the database. Like listing its feature types, which you can do via REST.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.