Creating new feature type with Geoserver REST API work but return error code 500 Planned...

What is the evidence that custom checks in Northern Ireland are going to result in violence?

Why do C and C++ allow the expression (int) + 4*5?

Why isn't everyone flabbergasted about Bran's "gift"?

Why doesn't the university give past final exams' answers?

Protagonist's race is hidden - should I reveal it?

Unix AIX passing variable and arguments to expect and spawn

Is "ein Herz wie das meine" an antiquated or colloquial use of the possesive pronoun?

How to renew schengen visas

What is the definining line between a helicopter and a drone a person can ride in?

Why do people think Winterfell crypts is the safest place for women, children & old people?

How to ask rejected full-time candidates to apply to teach individual courses?

How do I overlay a PNG over two videos (one video overlays another) in one command using FFmpeg?

Why not use the yoke to control yaw, as well as pitch and roll?

How to mute a string and play another at the same time

"Destructive force" carried by a B-52?

Is there a way to convert Wolfram Language expression to string?

Like totally amazing interchangeable sister outfit accessory swapping or whatever

What's the connection between Mr. Nancy and fried chicken?

Pointing to problems without suggesting solutions

How do I deal with an erroneously large refund?

When speaking, how do you change your mind mid-sentence?

Lights are flickering on and off after accidentally bumping into light switch

Why does my GNOME settings mention "Moto C Plus"?

xkeyval -- read keys from file



Creating new feature type with Geoserver REST API work but return error code 500



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Geoserver Rest folder not foundSLD file already existsCreating a geoserver layer with curl (but with a bounding box)Add external WFS layer to geoserver using REST APIGeoserver WFS-T “Feature type 'Workspace:Layer' is not available” Error on update / deleteCreating image pyramid datastore using GeoServer REST API?Geoserver on MacHttp 500 error when creating workspace using GeoServer REST-APIPublishing PostGIS Tables via Geoserver REST API returns Schema does not exist until I have to ReSave the workspace from Admin UIGeoServer - page not found http error 404





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







3















I'm using Geoserver REST API to create a new PostGIS feature type in Geoserver doing a POST to an url following this pattern http://localhost:8080/geoserver/rest/workspaces/my_ws/datastores/my_ds/featuretypes.json



and passing it data like this:



{'featureType': {'name':'my_featuretype_name'}}.



The post effectively create the feature type but is returning a 500 code error which mean:




Internal server error.




According to the official doc the returned code is supposed to be 201.



Looking in Geoserver log show me the following error:




INFO [org.geoserver] - Loaded feature type 'my_featuretype_name', enabled



ERROR [geoserver.rest] - :Resource named 'my_featuretype_name' already exists in store: 'my_ds'




The table already exist in my database but is not published as a layer in Geoserver.



What I want to do is to reproduce, with the REST API, the exact same action of clicking publish for an existing table in my database in the add new layer page of the Geoserver Web admin.



Am I doing something wrong?



Thanks a lot



Etienne










share|improve this question

























  • I am having this same issue using gsconfig (a Python module to manage GeoServer via rest). It seems to have worked once, but now it doesn't - and the purpose of what I am working on is to clear and recreate layers, so that's a huge problem. Did you ever find a solution to this?

    – William Kappler
    Nov 11 '16 at 22:25




















3















I'm using Geoserver REST API to create a new PostGIS feature type in Geoserver doing a POST to an url following this pattern http://localhost:8080/geoserver/rest/workspaces/my_ws/datastores/my_ds/featuretypes.json



and passing it data like this:



{'featureType': {'name':'my_featuretype_name'}}.



The post effectively create the feature type but is returning a 500 code error which mean:




Internal server error.




According to the official doc the returned code is supposed to be 201.



Looking in Geoserver log show me the following error:




INFO [org.geoserver] - Loaded feature type 'my_featuretype_name', enabled



ERROR [geoserver.rest] - :Resource named 'my_featuretype_name' already exists in store: 'my_ds'




The table already exist in my database but is not published as a layer in Geoserver.



What I want to do is to reproduce, with the REST API, the exact same action of clicking publish for an existing table in my database in the add new layer page of the Geoserver Web admin.



Am I doing something wrong?



Thanks a lot



Etienne










share|improve this question

























  • I am having this same issue using gsconfig (a Python module to manage GeoServer via rest). It seems to have worked once, but now it doesn't - and the purpose of what I am working on is to clear and recreate layers, so that's a huge problem. Did you ever find a solution to this?

    – William Kappler
    Nov 11 '16 at 22:25
















3












3








3








I'm using Geoserver REST API to create a new PostGIS feature type in Geoserver doing a POST to an url following this pattern http://localhost:8080/geoserver/rest/workspaces/my_ws/datastores/my_ds/featuretypes.json



and passing it data like this:



{'featureType': {'name':'my_featuretype_name'}}.



The post effectively create the feature type but is returning a 500 code error which mean:




Internal server error.




According to the official doc the returned code is supposed to be 201.



Looking in Geoserver log show me the following error:




INFO [org.geoserver] - Loaded feature type 'my_featuretype_name', enabled



ERROR [geoserver.rest] - :Resource named 'my_featuretype_name' already exists in store: 'my_ds'




The table already exist in my database but is not published as a layer in Geoserver.



What I want to do is to reproduce, with the REST API, the exact same action of clicking publish for an existing table in my database in the add new layer page of the Geoserver Web admin.



Am I doing something wrong?



Thanks a lot



Etienne










share|improve this question
















I'm using Geoserver REST API to create a new PostGIS feature type in Geoserver doing a POST to an url following this pattern http://localhost:8080/geoserver/rest/workspaces/my_ws/datastores/my_ds/featuretypes.json



and passing it data like this:



{'featureType': {'name':'my_featuretype_name'}}.



The post effectively create the feature type but is returning a 500 code error which mean:




Internal server error.




According to the official doc the returned code is supposed to be 201.



Looking in Geoserver log show me the following error:




INFO [org.geoserver] - Loaded feature type 'my_featuretype_name', enabled



ERROR [geoserver.rest] - :Resource named 'my_featuretype_name' already exists in store: 'my_ds'




The table already exist in my database but is not published as a layer in Geoserver.



What I want to do is to reproduce, with the REST API, the exact same action of clicking publish for an existing table in my database in the add new layer page of the Geoserver Web admin.



Am I doing something wrong?



Thanks a lot



Etienne







geoserver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 17 '13 at 20:53







Etienne Desgagné

















asked Jun 17 '13 at 20:45









Etienne DesgagnéEtienne Desgagné

5371415




5371415













  • I am having this same issue using gsconfig (a Python module to manage GeoServer via rest). It seems to have worked once, but now it doesn't - and the purpose of what I am working on is to clear and recreate layers, so that's a huge problem. Did you ever find a solution to this?

    – William Kappler
    Nov 11 '16 at 22:25





















  • I am having this same issue using gsconfig (a Python module to manage GeoServer via rest). It seems to have worked once, but now it doesn't - and the purpose of what I am working on is to clear and recreate layers, so that's a huge problem. Did you ever find a solution to this?

    – William Kappler
    Nov 11 '16 at 22:25



















I am having this same issue using gsconfig (a Python module to manage GeoServer via rest). It seems to have worked once, but now it doesn't - and the purpose of what I am working on is to clear and recreate layers, so that's a huge problem. Did you ever find a solution to this?

– William Kappler
Nov 11 '16 at 22:25







I am having this same issue using gsconfig (a Python module to manage GeoServer via rest). It seems to have worked once, but now it doesn't - and the purpose of what I am working on is to clear and recreate layers, so that's a huge problem. Did you ever find a solution to this?

– William Kappler
Nov 11 '16 at 22:25












1 Answer
1






active

oldest

votes


















0














I sent this json, and change neccessary with f-string. I think the problem is the same name of publicated layer and data source. May be it helps.



def publicate_shp(input_shp, host = "http://localhost:8080/geoserver", workspace = "raster_test"):

print ("Publicate shp")
shp_name = os.path.basename(input_shp)

json_shp_layer=({
"featureType": {
"name": f'''{shp_name[:-4]}''',
"nativeName": f'''{shp_name[:-4]}''',
"namespace": {
"name": f'''{workspace}''',
"href": f'''{host}/rest/namespaces/{workspace}.json'''
},
"title": f'''{shp_name[:-4]}''',
"keywords": {
"string": [
"features"
]
},
"nativeCRS": {
"@class": "projected",
"$": "PROJCS["WGS 84 / Pseudo-Mercator", rn GEOGCS["WGS 84", rn DATUM["World Geodetic System 1984", rn SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], rn AUTHORITY["EPSG","6326"]], rn PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], rn UNIT["degree", 0.017453292519943295], rn AXIS["Geodetic longitude", EAST], rn AXIS["Geodetic latitude", NORTH], rn AUTHORITY["EPSG","4326"]], rn PROJECTION["Popular Visualisation Pseudo Mercator", AUTHORITY["EPSG","1024"]], rn PARAMETER["semi_minor", 6378137.0], rn PARAMETER["latitude_of_origin", 0.0], rn PARAMETER["central_meridian", 0.0], rn PARAMETER["scale_factor", 1.0], rn PARAMETER["false_easting", 0.0], rn PARAMETER["false_northing", 0.0], rn UNIT["m", 1.0], rn AXIS["Easting", EAST], rn AXIS["Northing", NORTH], rn AUTHORITY["EPSG","3857"]]"
},
"srs": "EPSG:3857",
"nativeBoundingBox": {
"minx": 5009288.460919382,
"maxx": 8349700.133080006,
"miny": 6482677.681155918,
"maxy": 10613937.178513382,
"crs": {
"@class": "projected",
"$": "EPSG:3857"
}
},
"latLonBoundingBox": {
"minx": 44.99920387007435,
"maxx": 75.00663247360572,
"miny": 50.20973437863392,
"maxy": 68.55500689494048,
"crs": "EPSG:4326"
},
"projectionPolicy": "FORCE_DECLARED",
"enabled": "true",
"store": {
"@class": "dataStore",
"name": f'''{workspace}:{shp_name}''',
"href": f'''{host}/rest/workspaces/{workspace}/datastores/{shp_name}.json'''
},
"maxFeatures": 0,
"numDecimals": 0,
"padWithZeros": "false",
"forcedDecimal": "false",
"overridingServiceSRS": "false",
"skipNumberMatched": "false",
"circularArcPresent": "false",
"attributes": {
"attribute": [
{
"name": "the_geom",
"minOccurs": 0,
"maxOccurs": 1,
"nillable": "true",
"binding": "org.locationtech.jts.geom.MultiLineString"
},
{
"name": "ID",
"minOccurs": 0,
"maxOccurs": 1,
"nillable": "true",
"binding": "java.lang.Long",
"length": 10
},
{
"name": "elev",
"minOccurs": 0,
"maxOccurs": 1,
"nillable": "true",
"binding": "java.lang.Double",
"length": 19
}
]
}
}
})


url = f'''{host}/rest/workspaces/{workspace}/datastores/{shp_name}/featuretypes'''

#print(json.dumps(json_shp_layer, indent = 4))


response = requests.post(url,
auth=credits,
headers = headers_main,
data = json.dumps(json_shp_layer))


print ('''Publicate shp - ''' + str(response.status_code))




share
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "79"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f63740%2fcreating-new-feature-type-with-geoserver-rest-api-work-but-return-error-code-500%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I sent this json, and change neccessary with f-string. I think the problem is the same name of publicated layer and data source. May be it helps.



    def publicate_shp(input_shp, host = "http://localhost:8080/geoserver", workspace = "raster_test"):

    print ("Publicate shp")
    shp_name = os.path.basename(input_shp)

    json_shp_layer=({
    "featureType": {
    "name": f'''{shp_name[:-4]}''',
    "nativeName": f'''{shp_name[:-4]}''',
    "namespace": {
    "name": f'''{workspace}''',
    "href": f'''{host}/rest/namespaces/{workspace}.json'''
    },
    "title": f'''{shp_name[:-4]}''',
    "keywords": {
    "string": [
    "features"
    ]
    },
    "nativeCRS": {
    "@class": "projected",
    "$": "PROJCS["WGS 84 / Pseudo-Mercator", rn GEOGCS["WGS 84", rn DATUM["World Geodetic System 1984", rn SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], rn AUTHORITY["EPSG","6326"]], rn PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], rn UNIT["degree", 0.017453292519943295], rn AXIS["Geodetic longitude", EAST], rn AXIS["Geodetic latitude", NORTH], rn AUTHORITY["EPSG","4326"]], rn PROJECTION["Popular Visualisation Pseudo Mercator", AUTHORITY["EPSG","1024"]], rn PARAMETER["semi_minor", 6378137.0], rn PARAMETER["latitude_of_origin", 0.0], rn PARAMETER["central_meridian", 0.0], rn PARAMETER["scale_factor", 1.0], rn PARAMETER["false_easting", 0.0], rn PARAMETER["false_northing", 0.0], rn UNIT["m", 1.0], rn AXIS["Easting", EAST], rn AXIS["Northing", NORTH], rn AUTHORITY["EPSG","3857"]]"
    },
    "srs": "EPSG:3857",
    "nativeBoundingBox": {
    "minx": 5009288.460919382,
    "maxx": 8349700.133080006,
    "miny": 6482677.681155918,
    "maxy": 10613937.178513382,
    "crs": {
    "@class": "projected",
    "$": "EPSG:3857"
    }
    },
    "latLonBoundingBox": {
    "minx": 44.99920387007435,
    "maxx": 75.00663247360572,
    "miny": 50.20973437863392,
    "maxy": 68.55500689494048,
    "crs": "EPSG:4326"
    },
    "projectionPolicy": "FORCE_DECLARED",
    "enabled": "true",
    "store": {
    "@class": "dataStore",
    "name": f'''{workspace}:{shp_name}''',
    "href": f'''{host}/rest/workspaces/{workspace}/datastores/{shp_name}.json'''
    },
    "maxFeatures": 0,
    "numDecimals": 0,
    "padWithZeros": "false",
    "forcedDecimal": "false",
    "overridingServiceSRS": "false",
    "skipNumberMatched": "false",
    "circularArcPresent": "false",
    "attributes": {
    "attribute": [
    {
    "name": "the_geom",
    "minOccurs": 0,
    "maxOccurs": 1,
    "nillable": "true",
    "binding": "org.locationtech.jts.geom.MultiLineString"
    },
    {
    "name": "ID",
    "minOccurs": 0,
    "maxOccurs": 1,
    "nillable": "true",
    "binding": "java.lang.Long",
    "length": 10
    },
    {
    "name": "elev",
    "minOccurs": 0,
    "maxOccurs": 1,
    "nillable": "true",
    "binding": "java.lang.Double",
    "length": 19
    }
    ]
    }
    }
    })


    url = f'''{host}/rest/workspaces/{workspace}/datastores/{shp_name}/featuretypes'''

    #print(json.dumps(json_shp_layer, indent = 4))


    response = requests.post(url,
    auth=credits,
    headers = headers_main,
    data = json.dumps(json_shp_layer))


    print ('''Publicate shp - ''' + str(response.status_code))




    share




























      0














      I sent this json, and change neccessary with f-string. I think the problem is the same name of publicated layer and data source. May be it helps.



      def publicate_shp(input_shp, host = "http://localhost:8080/geoserver", workspace = "raster_test"):

      print ("Publicate shp")
      shp_name = os.path.basename(input_shp)

      json_shp_layer=({
      "featureType": {
      "name": f'''{shp_name[:-4]}''',
      "nativeName": f'''{shp_name[:-4]}''',
      "namespace": {
      "name": f'''{workspace}''',
      "href": f'''{host}/rest/namespaces/{workspace}.json'''
      },
      "title": f'''{shp_name[:-4]}''',
      "keywords": {
      "string": [
      "features"
      ]
      },
      "nativeCRS": {
      "@class": "projected",
      "$": "PROJCS["WGS 84 / Pseudo-Mercator", rn GEOGCS["WGS 84", rn DATUM["World Geodetic System 1984", rn SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], rn AUTHORITY["EPSG","6326"]], rn PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], rn UNIT["degree", 0.017453292519943295], rn AXIS["Geodetic longitude", EAST], rn AXIS["Geodetic latitude", NORTH], rn AUTHORITY["EPSG","4326"]], rn PROJECTION["Popular Visualisation Pseudo Mercator", AUTHORITY["EPSG","1024"]], rn PARAMETER["semi_minor", 6378137.0], rn PARAMETER["latitude_of_origin", 0.0], rn PARAMETER["central_meridian", 0.0], rn PARAMETER["scale_factor", 1.0], rn PARAMETER["false_easting", 0.0], rn PARAMETER["false_northing", 0.0], rn UNIT["m", 1.0], rn AXIS["Easting", EAST], rn AXIS["Northing", NORTH], rn AUTHORITY["EPSG","3857"]]"
      },
      "srs": "EPSG:3857",
      "nativeBoundingBox": {
      "minx": 5009288.460919382,
      "maxx": 8349700.133080006,
      "miny": 6482677.681155918,
      "maxy": 10613937.178513382,
      "crs": {
      "@class": "projected",
      "$": "EPSG:3857"
      }
      },
      "latLonBoundingBox": {
      "minx": 44.99920387007435,
      "maxx": 75.00663247360572,
      "miny": 50.20973437863392,
      "maxy": 68.55500689494048,
      "crs": "EPSG:4326"
      },
      "projectionPolicy": "FORCE_DECLARED",
      "enabled": "true",
      "store": {
      "@class": "dataStore",
      "name": f'''{workspace}:{shp_name}''',
      "href": f'''{host}/rest/workspaces/{workspace}/datastores/{shp_name}.json'''
      },
      "maxFeatures": 0,
      "numDecimals": 0,
      "padWithZeros": "false",
      "forcedDecimal": "false",
      "overridingServiceSRS": "false",
      "skipNumberMatched": "false",
      "circularArcPresent": "false",
      "attributes": {
      "attribute": [
      {
      "name": "the_geom",
      "minOccurs": 0,
      "maxOccurs": 1,
      "nillable": "true",
      "binding": "org.locationtech.jts.geom.MultiLineString"
      },
      {
      "name": "ID",
      "minOccurs": 0,
      "maxOccurs": 1,
      "nillable": "true",
      "binding": "java.lang.Long",
      "length": 10
      },
      {
      "name": "elev",
      "minOccurs": 0,
      "maxOccurs": 1,
      "nillable": "true",
      "binding": "java.lang.Double",
      "length": 19
      }
      ]
      }
      }
      })


      url = f'''{host}/rest/workspaces/{workspace}/datastores/{shp_name}/featuretypes'''

      #print(json.dumps(json_shp_layer, indent = 4))


      response = requests.post(url,
      auth=credits,
      headers = headers_main,
      data = json.dumps(json_shp_layer))


      print ('''Publicate shp - ''' + str(response.status_code))




      share


























        0












        0








        0







        I sent this json, and change neccessary with f-string. I think the problem is the same name of publicated layer and data source. May be it helps.



        def publicate_shp(input_shp, host = "http://localhost:8080/geoserver", workspace = "raster_test"):

        print ("Publicate shp")
        shp_name = os.path.basename(input_shp)

        json_shp_layer=({
        "featureType": {
        "name": f'''{shp_name[:-4]}''',
        "nativeName": f'''{shp_name[:-4]}''',
        "namespace": {
        "name": f'''{workspace}''',
        "href": f'''{host}/rest/namespaces/{workspace}.json'''
        },
        "title": f'''{shp_name[:-4]}''',
        "keywords": {
        "string": [
        "features"
        ]
        },
        "nativeCRS": {
        "@class": "projected",
        "$": "PROJCS["WGS 84 / Pseudo-Mercator", rn GEOGCS["WGS 84", rn DATUM["World Geodetic System 1984", rn SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], rn AUTHORITY["EPSG","6326"]], rn PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], rn UNIT["degree", 0.017453292519943295], rn AXIS["Geodetic longitude", EAST], rn AXIS["Geodetic latitude", NORTH], rn AUTHORITY["EPSG","4326"]], rn PROJECTION["Popular Visualisation Pseudo Mercator", AUTHORITY["EPSG","1024"]], rn PARAMETER["semi_minor", 6378137.0], rn PARAMETER["latitude_of_origin", 0.0], rn PARAMETER["central_meridian", 0.0], rn PARAMETER["scale_factor", 1.0], rn PARAMETER["false_easting", 0.0], rn PARAMETER["false_northing", 0.0], rn UNIT["m", 1.0], rn AXIS["Easting", EAST], rn AXIS["Northing", NORTH], rn AUTHORITY["EPSG","3857"]]"
        },
        "srs": "EPSG:3857",
        "nativeBoundingBox": {
        "minx": 5009288.460919382,
        "maxx": 8349700.133080006,
        "miny": 6482677.681155918,
        "maxy": 10613937.178513382,
        "crs": {
        "@class": "projected",
        "$": "EPSG:3857"
        }
        },
        "latLonBoundingBox": {
        "minx": 44.99920387007435,
        "maxx": 75.00663247360572,
        "miny": 50.20973437863392,
        "maxy": 68.55500689494048,
        "crs": "EPSG:4326"
        },
        "projectionPolicy": "FORCE_DECLARED",
        "enabled": "true",
        "store": {
        "@class": "dataStore",
        "name": f'''{workspace}:{shp_name}''',
        "href": f'''{host}/rest/workspaces/{workspace}/datastores/{shp_name}.json'''
        },
        "maxFeatures": 0,
        "numDecimals": 0,
        "padWithZeros": "false",
        "forcedDecimal": "false",
        "overridingServiceSRS": "false",
        "skipNumberMatched": "false",
        "circularArcPresent": "false",
        "attributes": {
        "attribute": [
        {
        "name": "the_geom",
        "minOccurs": 0,
        "maxOccurs": 1,
        "nillable": "true",
        "binding": "org.locationtech.jts.geom.MultiLineString"
        },
        {
        "name": "ID",
        "minOccurs": 0,
        "maxOccurs": 1,
        "nillable": "true",
        "binding": "java.lang.Long",
        "length": 10
        },
        {
        "name": "elev",
        "minOccurs": 0,
        "maxOccurs": 1,
        "nillable": "true",
        "binding": "java.lang.Double",
        "length": 19
        }
        ]
        }
        }
        })


        url = f'''{host}/rest/workspaces/{workspace}/datastores/{shp_name}/featuretypes'''

        #print(json.dumps(json_shp_layer, indent = 4))


        response = requests.post(url,
        auth=credits,
        headers = headers_main,
        data = json.dumps(json_shp_layer))


        print ('''Publicate shp - ''' + str(response.status_code))




        share













        I sent this json, and change neccessary with f-string. I think the problem is the same name of publicated layer and data source. May be it helps.



        def publicate_shp(input_shp, host = "http://localhost:8080/geoserver", workspace = "raster_test"):

        print ("Publicate shp")
        shp_name = os.path.basename(input_shp)

        json_shp_layer=({
        "featureType": {
        "name": f'''{shp_name[:-4]}''',
        "nativeName": f'''{shp_name[:-4]}''',
        "namespace": {
        "name": f'''{workspace}''',
        "href": f'''{host}/rest/namespaces/{workspace}.json'''
        },
        "title": f'''{shp_name[:-4]}''',
        "keywords": {
        "string": [
        "features"
        ]
        },
        "nativeCRS": {
        "@class": "projected",
        "$": "PROJCS["WGS 84 / Pseudo-Mercator", rn GEOGCS["WGS 84", rn DATUM["World Geodetic System 1984", rn SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], rn AUTHORITY["EPSG","6326"]], rn PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], rn UNIT["degree", 0.017453292519943295], rn AXIS["Geodetic longitude", EAST], rn AXIS["Geodetic latitude", NORTH], rn AUTHORITY["EPSG","4326"]], rn PROJECTION["Popular Visualisation Pseudo Mercator", AUTHORITY["EPSG","1024"]], rn PARAMETER["semi_minor", 6378137.0], rn PARAMETER["latitude_of_origin", 0.0], rn PARAMETER["central_meridian", 0.0], rn PARAMETER["scale_factor", 1.0], rn PARAMETER["false_easting", 0.0], rn PARAMETER["false_northing", 0.0], rn UNIT["m", 1.0], rn AXIS["Easting", EAST], rn AXIS["Northing", NORTH], rn AUTHORITY["EPSG","3857"]]"
        },
        "srs": "EPSG:3857",
        "nativeBoundingBox": {
        "minx": 5009288.460919382,
        "maxx": 8349700.133080006,
        "miny": 6482677.681155918,
        "maxy": 10613937.178513382,
        "crs": {
        "@class": "projected",
        "$": "EPSG:3857"
        }
        },
        "latLonBoundingBox": {
        "minx": 44.99920387007435,
        "maxx": 75.00663247360572,
        "miny": 50.20973437863392,
        "maxy": 68.55500689494048,
        "crs": "EPSG:4326"
        },
        "projectionPolicy": "FORCE_DECLARED",
        "enabled": "true",
        "store": {
        "@class": "dataStore",
        "name": f'''{workspace}:{shp_name}''',
        "href": f'''{host}/rest/workspaces/{workspace}/datastores/{shp_name}.json'''
        },
        "maxFeatures": 0,
        "numDecimals": 0,
        "padWithZeros": "false",
        "forcedDecimal": "false",
        "overridingServiceSRS": "false",
        "skipNumberMatched": "false",
        "circularArcPresent": "false",
        "attributes": {
        "attribute": [
        {
        "name": "the_geom",
        "minOccurs": 0,
        "maxOccurs": 1,
        "nillable": "true",
        "binding": "org.locationtech.jts.geom.MultiLineString"
        },
        {
        "name": "ID",
        "minOccurs": 0,
        "maxOccurs": 1,
        "nillable": "true",
        "binding": "java.lang.Long",
        "length": 10
        },
        {
        "name": "elev",
        "minOccurs": 0,
        "maxOccurs": 1,
        "nillable": "true",
        "binding": "java.lang.Double",
        "length": 19
        }
        ]
        }
        }
        })


        url = f'''{host}/rest/workspaces/{workspace}/datastores/{shp_name}/featuretypes'''

        #print(json.dumps(json_shp_layer, indent = 4))


        response = requests.post(url,
        auth=credits,
        headers = headers_main,
        data = json.dumps(json_shp_layer))


        print ('''Publicate shp - ''' + str(response.status_code))





        share











        share


        share










        answered 1 min ago









        Андрей ТарасовАндрей Тарасов

        11




        11






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f63740%2fcreating-new-feature-type-with-geoserver-rest-api-work-but-return-error-code-500%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            (145452) 2005 RN43 Классификация | Примечания | Ссылки |...

            Щит и меч (фильм) Содержание Названия серий | Сюжет |...

            Энтрерриос (город) Содержание История | Географическое...