0

I try uploading a NuGet package to Nexus using Curl from command line, but I get the error 400.
The package is not in the repository.

ls -l azure.core.1.24.0.nupkg
-rw-rw-r--. 1 ec2-user ec2-user 666796 Jun  8 11:58 azure.core.1.24.0.nupkg

curl -v   -u admin:pwd --upload-file ./azure.core.1.24.0.nupkg  http://10.20.1.78:8081/repository/package_nuget_for_portal/azure.core.1.24.0.nupkg
*   Trying 10.211.1.78...
* TCP_NODELAY set
* Connected to 10.20.1.78 (10.20.1.78) port 8081 (#0)
* Server auth using Basic with user 'admin'
> PUT /repository/package_nuget_for_portal/azure.core.1.24.0.nupkg HTTP/1.1
> Host: 10.20.1.78:8081
> Authorization: Basic YWRtaW46MXEydzNlNHI=
> User-Agent: curl/7.61.1
> Accept: */*
> Content-Length: 666796
> Expect: 100-continue
>
< HTTP/1.1 400 Bad Request
< Date: Sun, 12 Jun 2022 07:49:12 GMT
< Server: Nexus/3.37.3-02 (OSS)
< X-Content-Type-Options: nosniff
< Content-Security-Policy: sandbox allow-forms allow-modals allow-popups allow-presentation allow-scripts allow-top-navigation
< X-XSS-Protection: 1; mode=block
< Content-Type: application/xml
< Content-Length: 228
< Connection: close
<
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code>400</code>
  <message xml:lang="en-US">Multipart request required</message>
</error>

What do I miss here?

Mofi
  • 46,139
  • 17
  • 80
  • 143

1 Answers1

0

Try adding -H "multipart/form-data" into Curl command:

curl -v -u admin:pwd -H "multipart/form-data" --upload-file ./azure.core.1.24.0.nupkg  http://10.20.1.78:8081/repository/package_nuget_for_portal/azure.core.1.24.0.nupkg

Or use the Nuget command:

nuget sources add -u admin -p pwd -name myName -Source http://10.20.1.78:8081/repository/package_nuget_for_portal/
nuget push ./azure.core.1.24.0.nupkg -Source http://10.20.1.78:8081/repository/package_nuget_for_portal/
Json P
  • 11
  • 3