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!

    Using API on PowerShell

    Scheduled Pinned Locked Moved Support
    2 Posts 2 Posters 62 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.
    • P Offline
      patrick.bungama_6441
      last edited by

      Hello,

      I am having some issues with ProGet API. I am trying to use Powershell in order to create, update feeds, and then add some retention rules. My script is based on this doc: https://docs.inedo.com/docs/proget/reference/api/feed-management.

      Here is the script:

      $progetApiUrl = "https://{server}/"
      $apiKey = "secret-api-key"
      
      #Force TLS 1.2
      [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
      $Header = @{"X-ApiKey" = $apiKey}
      $uri = "$progetApiUrl/api/management/feeds/create/"
      $Body = @{name="example";feedType="universal";active=$true}
      
      $response = Invoke-RestMethod -Method POST -Uri $uri -ContentType "application/json" -Headers $Header -Body ( $Body | ConvertTo-Json)
      

      A sample response is:

      • The api documentation: https://github.com/Inedo/inedo-docs/blob/master/ProGet/reference/api/native.htm

      Using that documentation, i have tried to create my feeds like this:

      $progetApiUrl = "https://{server}/"
      $apiKey = "secret-api-key"
      #Force TLS 1.2
      [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
      $Header = @{"X-ApiKey" = $apiKey}
      $uri = "$progetApiUrl/Feeds_CreateFeed"
      
      $body = @{
              Feed_Name = "example";
              FeedType_Name = "universal";
              FeedConfiguration_Xml = '<Inedo.ProGet.Feeds.NuGet.NuGetFeedConfig Assembly="ProGetCoreEx">
                     <Properties SymbolServerEnabled="True"          				  			   	 
                                         StripSymbolFiles="True"
                                  	   UseLegacyVersioning="False" />
                  	</Inedo.ProGet.Feeds.NuGet.NuGetFeedConfig>'
              }
      
      $response = Invoke-RestMethod -Method POST -Uri $uri -ContentType "application/json" -Headers $Header -Body ( $body | ConvertTo-Json)
      

      The response is a Feed_Id. But the feed has some issues when i am trying to access it. I have this error:
      Server Error in '/' Application.
      Specified argument was out of the range of valid values.
      Parameter name: code

      [ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
      Parameter name: code]
         Inedo.Data.DataDomain`1.GetName(String code) +551
         Inedo.ProGet.WebApplication.Pages.Feeds.BrowseFeedPage.CreateChildControls() +436
         Inedo.ProGet.WebApplication.Pages.<InitializeAsync>d__2.MoveNext() +197
         System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
         System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
         Inedo.Web.PageFree.<ProcessRequestAsync>d__46.MoveNext() +279
         System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
         System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
         System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) +64
         Inedo.Web.Handlers.AsyncHandlerWrapper.EndProcessRequest(IAsyncResult result) +33
         System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +602
         System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
         System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +128
      

      The only way to manage the feed is by using the administration url in a browser:

      • https://{server}/administration/feeds/manage-feed?feedId=xxxx
        So, it is possible to modify the feed and even to delete it.

      Can you please give me a sample way to do that using the API?

      1 Reply Last reply Reply Quote 0
      • apxltdA Offline
        apxltd inedo-engineer
        last edited by

        The first example you mentioned (i.e. the one to /api/management/feeds/create) is using the Feeds Management API; it looks ok to me on first glance... can you share the error message you got when invoking it? You should be able to see logged request/responses in the Admin > API Keys as well.

        The second example you mentioned (Feeds_CreateFeed) is using the Native API, which we don't really recommend if there's an alternative available. It is basically a wrapper around stored procedures and the database. But in this case, it looks mostly correct, but the FeedType_Name is wrong; if you look at the Feeds table in the database, you'll see a universal feed is actually called ProGet in the database.

        Anyways, please use /api/management/feeds because it's easier to use and won't change if we update the database or stored procs.

        Founder and CEO, Inedo

        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