Trying to update an ArcGIS Online hosted feature serviceDescription using admin rest api

422
8
02-18-2024 07:30 PM
Labels (1)
ChrisCrowe
New Contributor II

I have an ArcGIS Online Hosted Feature Service.

I am trying to perform an updateDefinition and update the serviceDescription of a hostedFeatureService.

I am passing this as the payload to the rest url

https://services.arcgis.com/abc/ArcGIS/rest/admin/services/CC_3_VMSData/FeatureServer/updateDefiniti...

ChrisCrowe_0-1708313275254.png

 

This appears correct as per https://developers.arcgis.com/rest/services-reference/enterprise/update-definition-feature-service-....

But I get the following error

 

 

 

 

{
    "error": {
        "code": 400,
        "message": "Unable to update feature service definition.",
        "details": [
            "Invalid definition for 'ServiceDescription'.",
            "Exception has been thrown by the target of an invocation."
        ]
    }
}

 

 

 

 

 

I can only set the serviceDescription to "", anything else returns the above message. 

Any thoughts on how to overcome this?

Chris

0 Kudos
8 Replies
MiguelParedes
Esri Contributor

Greetings  @ChrisCrowe 

How are you trying to accomplish this?  One way of doing it is as follows:

Go to the Item page of the hosted feature layer you'd like to change, go to the bottom-right of the page and click URL "View". This will take you to the ArcGIS REST Service Directory for the layer. On the Top-right, click Admin, which will put you in Admin mode (the colour banner goes from light blue to "salmon". then go to the bottom of the page and click "Update Definition".  This will open the Update Service Definition - <layer_name>.  In the "Update Service Definition" text box, you will see the JSON for the layer.. "serviceDescription" should be line 36. Change the definition to what you want and set the format to "JSON", if that's what you want.  Then click the Update Service Definition button.  That should do it.

It would look something like the following: 

on9WFmYCtM.jpg

Hope the above works for you.

Miguel
0 Kudos
ChrisCrowe
New Contributor II

Thanks @MiguelParedes 

But I still get the exact same message if I leave all of the JSON and just update the serviceDescription property,

{

"error": {
"code": 400,
"message": "Unable to update feature service definition.",
"details": [
"Invalid definition for 'ServiceDescription'.",
"Exception has been thrown by the target of an invocation."
]
}

} 

The feature service is hosted on 11.2

Chris

0 Kudos
MiguelParedes
Esri Contributor

Greetings @ChrisCrowe 

Sorry, I didn't get this was for Portal 11.2.

I have just tested this in a test Enterprise Portal 11.2:

MiguelParedes_0-1708351445854.png

and the response was:

MiguelParedes_1-1708351491449.png

When I check the page again:

MiguelParedes_3-1708351656276.png

The Service Description now shows the new value.

Give that a go and see if it works for you.

Miguel
0 Kudos
ChrisCrowe
New Contributor II

@MiguelParedes 

I have no problem with 11.2 on ArcGIS Enterprise, it works as expected.

Just 11.2 on ArcGIS Online.

Not sure any of these headers will help - they are the response headers from the server.

X-Amz-Cf-Id: Axj_6CHPi6EPfkzGts3WQE6t4hd9SNmhKyaDvJq-w5mmEC9xG_qqLA==
X-Amz-Cf-Pop: SFO53-P2
X-Arcgis-Correlation-Id: 00-bc3d3e1a5a1bc38183c564756bc4b4f6-99e41c9396020c5a-00
X-Arcgis-Instance:5yk64u4ec00000P
X-Arcgis-Trace-Id:bc3d3e1a5a1bc38183c564756bc4b4f6
X-Arcgis-Upstream:us1h00c00
X-Cache:Miss from cloudfront

 

 Running the Info rest end point I get this back

{
"currentVersion": 11.2,
"fullVersion": "11.2.0",
"owningSystemUrl": "https://www.arcgis.com",
"owningTenant": "X3EAXo......vCvV",
"authInfo": {
"isTokenBasedSecurity": true,
"tokenServicesUrl": "https://www.arcgis.com/sharing/generateToken"
}
}

 

Chris

 

0 Kudos
MiguelParedes
Esri Contributor

Greetings @ChrisCrowe 

Sorry if I am misunderstanding what you are asking for, but I am afraid I don't understand what you mean by "I have no problem with 11.2 on ArcGIS Enterprise, it works as expected."

11.2 is the version of ArcGIS Enterprise you are working on. Isn't it?   So what do you mean by " 11.2 on ArcGIS Online?"

In a previous message, you say "The feature service is hosted on 11.2"  Does this mean that you are then registering that service URL in an ArcGIS Online organisation site?  But if that is the case, how come the original URL of the service on your first post is https://services.arcgis.com/abc/ArcGIS/rest/admin/services/CC_3_VMSData/FeatureServer/updateDefiniti... which is an ArcGIS Online service?  Was the Portal 11.2 service shared with ArcGIS Online via Distributed Collaboration as a copy?

Miguel
0 Kudos
ChrisCrowe
New Contributor II

@MiguelParedes 

Hi, sorry I confused you. I have done some more testing with what I call ArcGIS Online - https://trimble.maps.arcgis.com/

That server says it is 11.2 if I look at the metadata.

I also have a access to another server running ArcGIS Enterprise 11.2

I have now successfully set the serviceDescription on the ArcGIS Online server. It seems that the initial definition that was used to create the service was causing the issue.

I created a new service using the very minimal definition below and I can then update the serviceDescription without issue.

{
	"name": "C1_VMSData",
	"serviceDescription": "schema version 1.0.7",
	"spatialReference": {
		"wkid": 102100
	},
	"initialExtent": {
		"xmin": -10030791.438290201,
		"ymin": 5157885.01266605,
		"xmax": -10029767.063734423,
		"ymax": 5158913.201985204,
		"spatialReference": {
			"wkid": 102100,
			"latestWkid": 3857
		}
	}
}

 

I will try to identify what property in the original definition caused the issue.

Chris

 

0 Kudos
ChrisCrowe
New Contributor II

@MiguelParedes 

I did some testing and my original definition contained this

 "xssPreventionInfo": {
    "xssPreventionEnabled": true,
    "xssPreventionRule": "input",
    "xssInputRule": "rejectInvalid"
  },

When I removed this the updateDefinition succeeded

Chris

 

0 Kudos
MiguelParedes
Esri Contributor

Greetings @ChrisCrowe 

Thank you for the clarification.

Interesting that you had to delete the section for "xssPreventionInfo".  According to the documentation here, the parameter is described as "A JSON object specifying the properties of cross-site scripting prevention".

I have checked a couple of hosted feature layers in an ArcGIS Online org and I can see that element configured as you described. However, I have no issues changing the "serviceDescription" parameter, so I am not sure why it was not working for you.

Thanks for reaching out.

Miguel
0 Kudos