ArcServer GP service, Have rest endpoint return Json

2497
2
Jump to solution
11-02-2015 08:38 AM
BillChappell
Occasional Contributor II

I've creates several GPS services some select features as a task but how can I get a GPS service to select features and return them as JSON, like you can with a featureService or by querying a MapService. I know there is a arcpy command to convert a fc to JSON but that just makes a file. When I run my GP services they say executed and successful but don't return data. Am I missing something?

The end result would be to hit the rest endpoint with a few parameters and get JSON back on the url page.

0 Kudos
1 Solution

Accepted Solutions
JonathanQuinn
Esri Notable Contributor

Do you have an output parameter within your GP service?  If not, set your final output as an output parameter and it'll be returning the the table of contents when run in ArcMap and as JSON when run in a web client or from REST.

View solution in original post

0 Kudos
2 Replies
JonathanQuinn
Esri Notable Contributor

Do you have an output parameter within your GP service?  If not, set your final output as an output parameter and it'll be returning the the table of contents when run in ArcMap and as JSON when run in a web client or from REST.

0 Kudos
BillChappell
Occasional Contributor II

Got it,

As a model it ran without defining the output, however as a python script you had to work it in the parameter GUI, I wish they had documented it somewhere Google would have found it.

I took the selected features in Python to CopyRows(Creates Table)  and then when making the parameters called it Output, said it was a Table, and selected direction Output in the parameter GUI (input was the default value), then in the python script make sure it said arcpy.GetParameter(5) not GetParameterAsTest(5) then I ran it and it worked.

I ran it in Sync mode and it returned JSON. Before I was writing back to my fileGDB now just using in_memory to avoid disk ops and it's faster and avoids multiple user conflicts.

Gotcha was "final output as an output parameter" miss this and it will want an existing table as input, throwing you a curve. Also setting it as Table not string, you want the object not name.

Now our programmers hit our GIS tables  and have some of the GIS functionality available through REST.

Bill

0 Kudos