Skip to main content
  • 10000+ Posts
  • 53,412 Replies
10000+ Posts
Uploading files using python via data upload service

I want to upload some files for a specific workbench using HTTP.I'm using Python for this with requests library, but I'm having difficulty getting it to work.My python code is as follows:    with open(file_path, 'rb') as file:        url = f"{fme_url}/fmedataupload/{script_location}"        data = {            'custom_file': {                'value': file.read(),                'options': {                    'contentType': 'application/octet-stream',                    'filename': file_name,                }            },            'opt_namespace': directory,            'opt_fullpath': True        }        token = get_token()        headers = {            'content-type': 'application/x-www-form-urlencoded',            'Authorization': f"fmetoken token={token}",        }        return requests.post(url, data=data, headers=headers, json=True)

Badge Winners

  • Welcome Back
    hafidushas earned the badge Welcome Back
  • Welcome Back
    zubeenhas earned the badge Welcome Back
  • Webinar Watcher (Bronze)
    davidatsafehas earned the badge Webinar Watcher (Bronze)
  • Online Training
    iskelton19has earned the badge Online Training
  • Student (Grey)
    NickAtSafehas earned the badge Student (Grey)
Show all badges

Community Stats

32,485
Posts
123,399
Replies
40,671
Members