[Geoserver-devel] [JIRA] (GEOS-9419) Adding SQL views via REST fails with JSON payload

Fadi created an issue

GeoServer / BugGEOS-9419

Adding SQL views via REST fails with JSON payload

Issue Type:

BugBug

Affects Versions:

2.15.2, 2.16.0

Assignee:

Unassigned

Created:

28/Nov/19 4:51 PM

Priority:

MediumMedium

Reporter:

Fadi

Creating a SQL view-based layer via REST with the following request:

curl -i --user admin:geoserver -X POST -H ‘Content-Type: application/json; charset=utf-8’ -d @test_post.json
http://localhost:{port}/geoserver/rest/workspaces/{test_workspace}/datastores/{test_store}/featuretypes’

according to the documentation for Post-request

and the content of test_post.json as following:

{
  "featureType": {
    "name": "test_post",
    "title": "test_post",
    "metadata": {
      "entry": {
        "key": "JDBC_VIRTUAL_TABLE",
        "virtualTable": {
          "name": "test_post",
          "sql": "select id, area, 'test' AS test from test"
        }
      }
    }
  }
}

returns HTTP/1.1 500 server error
Schema ‘test_post’ does not exist
Noticed : omitting the “name” attribute from featureType turns the error into Schema ‘null’ does not exist

This works fine with XML, using the same with test_post.xml
curl -i --user admin:geoserver -X POST -H ‘Content-Type: text/xml; charset=utf-8’ -d @test_post.xml
http://localhost:{port}/geoserver/rest/workspaces/{test_workspace}/datastores/{test_store}/featuretypes’

test_post.xml :

<featureType>
    <name>test_post</name>
    <title>test_post</title>
    <metadata>
        <entry key="JDBC_VIRTUAL_TABLE">
            <virtualTable>
                <name>test_post</name>
                <sql>
                    select id, area, 'test' AS test from test
                </sql>
            </virtualTable>
        </entry>
    </metadata>
</featureType>

–> HTTP/1.1 201 Created

Add Comment

Add Comment

Get Jira notifications on your phone! Download the Jira Cloud app for Android or iOS


This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100114-sha1:654add4)

Atlassian logo