Hi.
I want to run a workspace using the Python script I have pasted here. But everytime I run it, I get the following error:
HTTP Error 422: Unprocessable Entity
My Python version is 2.7.
FME Server 2016
Thanks for any help provided!
import urllib2
import json
SERVER_URL = "http://100.100.100.100"
REPOSITORY = "MyRepo"
WORKSPACE = "First%20Test.fmw"
TOKEN = "ddddddddddddddddddddddddddddddddddddddddddddddddd"
# Set up the published parameters as object
params = {
"publishedParameters" : [
{
"name" : "path_1",
"value" : "C:\test1"
},
{
"name" : "path_2",
"value" : "C:\test2"
}
]
}
url = '{0}/fmerest/v2/transformations/commands/submit/{1}/{2}'.format(SERVER_URL, REPOSITORY, WORKSPACE)
# Request constructor expects bytes, so we need to encode the string
body = json.dumps(params).encode('utf-8')
headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization' : 'fmetoken token={0}'.format(TOKEN)
}
# This will use POST, since we are including data
req = urllib2.Request(url, body, headers)
r = urllib2.urlopen(req)
print('Request status: ' + str(r.status))
resp = r.read()
resp = resp.decode('utf-8')
resp = json.loads(resp)
if r.status == 202:
print('Job ID is {0}'.format(resp['id']))