Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login
    1. Home
    2. patrick.bungama_6441
    3. Posts

    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!

    P Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Groups 0

    Posts

    Recent Best Controversial
    • Using API on PowerShell

      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?

      posted in Support
      P
      patrick.bungama_6441
    • 1 / 1