Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmkasun/913d0cf3d236195bc2d1b1f9f89e827d to your computer and use it in GitHub Desktop.
Save tmkasun/913d0cf3d236195bc2d1b1f9f89e827d to your computer and use it in GitHub Desktop.
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