Created
October 25, 2016 17:02
-
-
Save tmkasun/913d0cf3d236195bc2d1b1f9f89e827d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_asset(metadata, file_name): | |
credentials = '{username}:{password}'.format(username=conf['username'], password=conf['password']) | |
auth_value = b64encode(credentials.encode()) | |
headers = { | |
'Authorization': '{type} {auth_value}'.format(type="Basic", auth_value=auth_value.decode()), | |
'Content-Type': 'application/json' | |
} | |
request_url = conf['artifact_endpoint'] | |
response = requests.post(request_url, data=metadata, headers=headers, verify=False) | |
if not response.ok: | |
print("Error while creating the asset {}".format(file_name)) | |
else: | |
print("Response Content = {}\nStatus Code = {}".format(response.content, response.status_code)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment