Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    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?

    Scheduled Pinned Locked Moved Support
    7 Posts 2 Posters 14 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      arozanski_1087
      last edited by

      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?

      atrippA 1 Reply Last reply Reply Quote 0
      • atrippA Offline
        atripp inedo-engineer @arozanski_1087
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • A Offline
          arozanski_1087
          last edited by

          @atripp

          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
          
          atrippA 1 Reply Last reply Reply Quote 0
          • atrippA Offline
            atripp inedo-engineer @arozanski_1087
            last edited by

            Hi @arozanski_1087

            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-tag

            If 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)
            A 1 Reply Last reply Reply Quote 0
            • A Offline
              arozanski_1087 @atripp
              last edited by

              @atripp

              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.

              atrippA 1 Reply Last reply Reply Quote 0
              • atrippA Offline
                atripp inedo-engineer @arozanski_1087
                last edited by

                Hi @arozanski_1087

                The method name is NpmFeeds_SetTagVersion so I think the error you're seeing is about case sensitivity in the method name.

                A 1 Reply Last reply Reply Quote 0
                • A Offline
                  arozanski_1087 @atripp
                  last edited by

                  @atripp you're the best.

                  I'll give these a shot and come back if i run into something i can't work through.

                  1 Reply Last reply Reply Quote 0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • 1 / 1
                  • First post
                    Last post
                  Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation