Delete nuget package via api with apikeys - 403 Forbidden - Sonatype Nexus Repository - Sonatype Community
Delete nuget package via api with apikeys - 403 Forbidden
post by Holger_Holgalin on Mar 10, 2025
Holger Holgalin
hi, im building a pipeline to promote nuget packages from one repo to another and since the pipeline executes on windows its via powershell. im using my own api key and my user has nx-all rights as i am just testing here and seeing how it works.
via the swagger i can delete the package via the id , no problems, but when i go via powershell i get 403
*UNKNOWN org.sonatype.nexus.siesta.internal.AuthorizationExceptionMapper - (ID 05c628e3-c54f-4a51-a48f-7d706bb02509) Response: [403] (no entity/body); mapped from: org.apache.shiro.authz.AuthorizationException
i can search via the api for package ids etc, its just the delete that doesnt work. do i have to enable something in nexus settings to be aple to delete via api?
ps code: Invoke-RestMethod -Uri https://$NexusUrl/service/rest/v1/components/$PackageId -Method Delete -Headers @{ “Authorization” = “apikey $ApiKey” }
post by mpiggott on Mar 11, 2025
Matthew Piggott
When you reference api key do you mean User Token? If you’re referencing NuGet API Key, those are only valid for NuGet repository endpoints not the REST API.
post by Holger_Holgalin on Mar 11, 2025
Holger Holgalin
Ok I kinda suspected that after digging some more. I must say the docs could be clearer about that .
I went username password instead .