Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
Is there a Proget API to set NPM tag version?
-
Someone in my organization was using the NugetFeeds_SetTagVersion endpoint to attempt to tag nugets. I'd like to try the same for NPM packages, but my api calls return with an error: Invoke-RestMethod : There is no API method named npmFeeds_SetTagVersion
Does this exist for NPM? Does proget have a swagger or other query-able API that can tell me the definitions of what's there?
-
Hi @arozanski_1087,
Do you mean that you are currently tagging npm packages via the API (
NpmFeeds_SetTagVersion
), but that you wish to tag NuGet packages?I ask, because there is no such method
NugetFeeds_SetTagVersion
, at least not in ProGet v6 or other versions that I'm aware of.It's also not possible to tag NuGet packages -- the reason is, the package tags are stored in the manifest file, and you would need to reupload the package file. npm tags, however, are stored as metadata on the server (not in the package manifest file).
The method
NpmFeeds_SetTagVersion
is part of the ProGet Native API, and you can find what methods are available in/reference/api
inside of your version of ProGet.Cheers,
Alana
-
What I mean is that I want to try to tag npm packages via the API. I found this in a build that wasn't finished that I am now responsible for. The engineer previously responsible for it has left our organization and I don't know where he got this or how, and this was not documented by him to my knowledge in any ticket he worked on.
Here's the actual API call I saw in our build in a custom powershell runner in Team City. The %variable% references are Team City syntax for how that software inserts its own variables into script runners.
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("Content-Type", "application/json") $body = "{ `n`"Feed_Name`" : `"npm`", `n`"FeedType_Name`" : `"npm`", `n`"API_Key`" : '%svc.proget.apikey%', `n`"Feed_Id`": 6, `n`"Package_Name`": '%package.name%', `n`"Scope_Name`": `"MyCompany`", `n`"Tag_Name`": `"latest`", `n`"Tag_Version`": '%app.version%' `n}" $response = Invoke-RestMethod "%svc.proget.host%/api/json/NugetFeeds_SetTagVersion" -Method 'POST' -Headers $headers -Body $body
-
Thanks for sharing that!
Based on the snippet you sent, my guess is that this was originally for a npm package, and someone tried to make it work for a NuGet package? But that would have never worked, b/c NuGet packages can't be tagged... so his is really just a broken / never worked code snippet.
To tag npm packages, I recommend you to just use the client:
https://docs.npmjs.com/cli/v8/commands/npm-dist-tagIf you want to use the native API, then note the parameters are also wrong. NpmFeeds_SetTagVersion uses these parameters
- Feed_Id (Int32)
- Package_Name (String)
- Scope_Name (String)
- Tag_Name (String)
- Tag_Version (String)
-
Are those APIs case sensitive? because I had originally tried to use npmFeeds_SetTagVersion and got the first error I posted
[16:07:11]Step 5/6: Proget: Apply tag to Latest Version (15s) [16:07:11][Step 5/6] Step 1/1: Apply Latest Tag to Version (PowerShell) (15s) [16:07:27][Step 1/1] Invoke-RestMethod : There is no API method named npmFeeds_SetTagVersion [16:07:27][Step 1/1] Error message: Invoke-RestMethod : There is no API method named npmFeeds_SetTagVersion [16:07:27][Step 1/1] At C:\TeamCity\BuildAgent\temp\buildTmp\powershell16555570498298526.ps1:25 char:13
I would have expected to get a 400 error from your API from my bad parameters making an invalid request instead of this.
-
The method name is
NpmFeeds_SetTagVersion
so I think the error you're seeing is about case sensitivity in the method name.
-
@atripp you're the best.
I'll give these a shot and come back if i run into something i can't work through.