I have a python script where I'm trying to upload an asset to nexus 3 using python requests library. The code I displayed below works for nexus 2. But as the rest api is changed for nexus 3 I'm finding difficulty to upload the assets to nexus 3.
I modified my payload to included the repository as well as asset1 file but it doesn't work. I also tried to include the header and converted to payload to json format, but no luck.
Any leads will be appreciated.
import requests
filename = 'content.zip'
url = "https://nexus3-url/repos/service/rest/v1/components?repository=maven-repo"
files = { 'filename': open(filename, 'rb') }
payload = {
'groupId' : 'group.id',
'asset1.extension' : 'zip',
'version' : '1.0.0',
'artifactId' : 'test',
'generate-pom' : 'false'
}
response = requests.post(url,
allow_redirects = False,
auth = requests.auth.HTTPBasicAuth(username, password),
files = files,
data = payload,
timeout = 20,
verify = cert,
)
The error message I get is requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: