# Example ML Studio API usage
#
# This example program:
# Creates a folder to hold the file in the ML Studio cloud
#
# Requires running under Python 3.x to avoid SSL request issues.
#
# Copyright 2017-2021 (c) InRule Technology, Inc.
import base64 # For encoding password
import string # For byte array to char array conversion
import requests # For HTTP requests (http://docs.python-requests.org)
# username and password is defined outside this file. Format
# of the credentials file:
# username = 'your username'
# password = 'your password'
import credentials as cred
# Network vars for requests
# Replace "YOURSERVER" or "YOURSERVER.simmachines.com" with your installation URL
cloudIpandPort = 'YOURSERVER.simmachines.com:8443'
rfprotocol = 'https'
baseurl = rfprotocol + '://' + cloudIpandPort + '/cloud'
createfolder_URL = baseurl + '/createFolder'
folder_name = "TestFolder"
createfolder_data = {'folderName': folder_name}
resp = requests.post(createfolder_URL, data=createfolder_data,
auth=requests.auth.HTTPBasicAuth(cred.username, cred.password))
print("Response: ", resp) # Should print 200 if successful
print("Response: ", resp.content)
This program produces the output:
Response: <Response [200]>
Response: b'{"name":"TestFolder","userName":"username","createdDate":1497632834238}'
Comments
0 comments
Please sign in to leave a comment.