Hi there,
We have a workbench that takes as input a KML file, processes it and outputs a zip file. After testing, this workbench has been uploaded to FME Server, and has data download capabilities.
We want this workbench process to be run via python, with the inputs of the workbench defined by the user. We are using Python to upload the user file to the Data folder (FME_SHAREDRESOURCE_DATA)
import requests
folderConnectionURL = "https://xxx/fmerest/v3/resources/connections/FME_SHAREDRESOURCE_DATA/filesys/pvDesign?createDirectories=false&overwrite=true"
uploadedFile = "zzz.kml"
os.rename(outKMZFileClipped, os.path.join(os.path.dirname(outKMZFileClipped), uploadedFile))
outFile = os.path.join(os.path.dirname(outKMZFileClipped), uploadedFile)
headers = {
'Authorization':'fmetoken token=token',
'Content-Disposition': f'attachment;filename={uploadedFile}',
'Accept': 'applicaton/json',
}
with open(outFile, 'rb') as kmlFile:
files= {'file':(outFile, kmlFile, 'application/octet-stream')}
uploadResponse = requests.post(folderConnectionURL, headers=headers, files=files)
print (uploadResponse.text)
And then once the file has been uploaded, we then want to use that file as the input parameter in a webhook. The webhook url is as follows:
fmeServerWebhookURL = f"https://xxx/fmedatadownload/Test/CheckForSelfIntersecting3.6.fmw"#?SourceDataset_OGCKML=%24(FME_SHAREDRESOURCE_DATA)%2fpvDesign%2f{os.path.basename(uploadedFile)}&DestDataset_SHAPEFILE=C%3output&opt_showresult=false&opt_servicemode=sync&token=token"
An attempt to upload the user files as the input uses the following code:
payload= {}
headers = {
'Authorization': 'fmetoken token=xyz',
}
fmeJobResponse = requests.request('POST',fmeServerWebhookURL, headers=headers, data=payload, allow_redirects=False)
print(fmeJobResponse.text)
However, the response is:
java.nio.file.AccessDeniedException: C:\ProgramData\Safe Software\FME Server\resources\system\temp\requestdata\6378309562036833286</div>
If manually run in a browser, the fmeServerWebhookURL states that the FME Data Download Service Completed Successfully, however with no output .zip file available to download.
What may be causing the request to fail, and is it actually possible to generate a webhook url with a parameter (uploaded to the Data folder) ?
Any python examples would be great.
Thanks