5

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?

Ian Turton
84k6 gold badges93 silver badges190 bronze badges
asked Jun 29, 2018 at 15:42
1
  • Could anybody please tell me if posting of this issue to geoserver users mailinglist is considered as cross-posting? Commented Jul 2, 2018 at 13:41

2 Answers 2

2

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.

answered Aug 22, 2019 at 7:52
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

answered Aug 22, 2019 at 7:05
1
  • 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. Commented Aug 22, 2019 at 7:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.