workflows with python
Hi,
I want to call a workflow with python, mainly I am having trouble getting it to recognise the passed in parameters.
I have this so far
url = 'http://GeoServer.au/Geocortex/Essentials/REST/sites/Ops/workflows/SiteBuffer/run?ReadyToRun=1'
inargs = {'aQueryID': '2391_10',
'aQueryType': 'LOCATION',
'aBuffer': 1000,
'aCurrencyFlag': 'F',
'f' : 'pjson'
}
response = requests.post(url, data=inargs)
print response.content
The idea is that it returns a list of the features within aBuffer (eg. 10000).It works fine from the GC endpoint but when called from Python it doesn't set the passed arguements.
Any clues.....Please
0
-
My solution to a similar issue was to run the workflow from the REST endpoint, then monitor to the network traffic using Chrome Developer Tools and see how the inargs were being passed in the request. Here are my input arguments: 
And here is how they were being passed in the request:inargs=%5B%0D%0A++%7B%0D%0A++++%22isRequired%22%3A+false%2C%0D%0A++++%22name%22%3A+%22minX%22%2C%0D%0A++++%22typeName%22%3A+%22System.Double%2C+mscorlib%22%2C%0D%0A++++%22runtimeTypeName%22%3A+%22System.Double%2C+mscorlib%22%2C%0D%0A++++%22value%22%3A+122%0D%0A++%7D%2C%0D%0A++%7B%0D%0A++++%22isRequired%22%3A+false%2C%0D%0A++++%22name%22%3A+%22minY%22%2C%0D%0A++++%22typeName%22%3A+%22System.Double%2C+mscorlib%22%2C%0D%0A++++%22runtimeTypeName%22%3A+%22System.Double%2C+mscorlib%22%2C%0D%0A++++%22value%22%3A+-18%0D%0A++%7D%2C%0D%0A++%7B%0D%0A++++%22isRequired%22%3A+false%2C%0D%0A++++%22name%22%3A+%22maxX%22%2C%0D%0A++++%22typeName%22%3A+%22System.Double%2C+mscorlib%22%2C%0D%0A++++%22runtimeTypeName%22%3A+%22System.Double%2C+mscorlib%22%2C%0D%0A++++%22value%22%3A+123%0D%0A++%7D%2C%0D%0A++%7B%0D%0A++++%22isRequired%22%3A+false%2C%0D%0A++++%22name%22%3A+%22maxY%22%2C%0D%0A++++%22typeName%22%3A+%22System.Double%2C+mscorlib%22%2C%0D%0A++++%22runtimeTypeName%22%3A+%22System.Double%2C+mscorlib%22%2C%0D%0A++++%22value%22%3A+-17%0D%0A++%7D%0D%0A%5D&workflow=&f=pjson&ReadyToRun=1I got rid of the "+" characters, then swapped out the hard coded coordinate values for placeholders. I then appended the inargs to the end of my workflow URL to form my request URL:from urllib2 import urlopen import json def get_jsonparsed_data(url): response = urlopen(url) data = response.read().decode("utf-8") return json.loads(data) minX = 122 maxX = 123 minY = -18 maxY = -17 url = ("http://GeoServer.au/Geocortex/Essentials/REST/" "sites/Dev/workflows/Report/run?inargs=%5B%0D%0A%7B%0D%0A%22" "isRequired%22%3Afalse%2C%0D%0A%22name%22%3A%22minX%22%2C%0D%0A%22" "typeName%22%3A%22System.Double%2Cmscorlib%22%2C%0D%0A%22" "runtimeTypeName%22%3A%22System.Double%2Cmscorlib%22%2C%0D%0A%22" "value%22%3A<b>{minX}</b>%0D%0A%7D%2C%0D%0A%7B%0D%0A%22" "isRequired%22%3Afalse%2C%0D%0A%22name%22%3A%22minY%22%2C%0D%0A%22" "typeName%22%3A%22System.Double%2Cmscorlib%22%2C%0D%0A%22" "runtimeTypeName%22%3A%22System.Double%2Cmscorlib%22%2C%0D%0A%22" "value%22%3A<b>{minY}</b>%0D%0A%7D%2C%0D%0A%7B%0D%0A%22" "isRequired%22%3Afalse%2C%0D%0A%22name%22%3A%22maxX%22%2C%0D%0A%22" "typeName%22%3A%22System.Double%2Cmscorlib%22%2C%0D%0A%22" "runtimeTypeName%22%3A%22System.Double%2Cmscorlib%22%2C%0D%0A%22" "value%22%3A<b>{maxX}</b>%0D%0A%7D%2C%0D%0A%7B%0D%0A%22" "isRequired%22%3Afalse%2C%0D%0A%22name%22%3A%22maxY%22%2C%0D%0A%22" "typeName%22%3A%22System.Double%2Cmscorlib%22%2C%0D%0A%22" "runtimeTypeName%22%3A%22System.Double%2Cmscorlib%22%2C%0D%0A%22" "value%22%3A<b>{maxY}</b>%0D%0A%7D%0D%0A%5D&workflow=&f=json&ReadyToRun=1" ).format(minX=minX, minY=minY, maxX=maxX, maxY=maxY) print(get_jsonparsed_data(url))
Hope this helps someone.0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
1 kommentar