Difficulty creating a view layer with REST API

351
0
04-11-2023 12:25 PM
LNX
by
New Contributor II

I'm attempting to programmatically create a view layer from an existing hosted feature layer in Portal running ArcGIS Enterprise 10.9.  I'm following this documentation.

 

 

In my case I don't need to join any tables.  I just need to apply a definition query to the source layer and have a new view layer created off of that.

I'm using Postman to send the request to /addToDefinition.  The token is being generated manually first, then added to the request as a parameter in the query string. The token is working.

My request URL for the POST is structured like this:

https://<myDomain>/server/rest/admin/services/Hosted/Articles_Enriched/FeatureServer/addToDefinition?f=json&token=<myToken>

I'm passing in the addToDefinition parameter as url-encoded form data.

{
    "layers": [
        {
            "name": "Test October 2022",
            "description": "",
            "adminLayerInfo": {
                "viewLayerDefinition": {
                    "table": {
                        "name": "target",
                        "sourceServiceName": "Articles_Enriched",
                        "sourceLayerId": 0,
                        "sourceLayerFields": [
                            {
                                "name": "article_title",
                                "source": "article_title"
                            },
                            {
                                "name": "article_text",
                                "source": "article_text"
                            }
                        ]
                    }
                }
            }
        }
    ]
}

 

The POST is being received by the Portal's REST API, however it returns the following error message:

{
    "error": {
        "code": 500,
        "message": "JSONObject[\"fields\"] not found.",
        "details": []
    }
}

 

 I'm confused why it requires a "fields" parameter and if so, where I need to include it?  In the documentation I linked above a "fields" parameter is only shown in the example where a whole layer definition is added, whereas I'm following the other example where an Advanced View is added instead, and in those examples there's no "fields" parameter in the request JSON.

What am I getting wrong here?

0 Replies