2

So, much research has shown that the only way to push a NuGet package to the VSTS Package Management is with the CLI tools vs the NuGet Package Explorer app. So, I'm hoping to fix that to make life easier.

Initial research makes me think that I can use one of the REST APIs that Microsoft offers. When I use the link below in Postman, I get the response back that would normally be the Microsoft login page, which is what I would expect when I'm not passing any authentication in the GET request.

https://fabrikam.feeds.visualstudio.com/DefaultCollection/_apis/packaging/feeds/EngineeringInternal/packages?api-version=2.0-preview

However, when I replace the demo account and feed name with my own, I get a 401 error.

https://sartainsoftwaresolutions.feeds.visualstudio.com/DefaultCollection/_apis/packaging/feeds/SartainSoftware.Common/packages?api-version=2.0-preview

Unless I have to enable access to the given API in my VSTS account, I'm not sure what I'm missing.

Any thoughts?

Community
  • 1
  • 1
Don Sartain
  • 557
  • 9
  • 25

1 Answers1

2

First, regarding 401 issue, you need to specify alternate authentication credential (Profile >Security > Alternate authentication credentials) or Personal access token (user name is empty, do not need to specify), you can’t use email account directly (e.g. xxx.hotmail.com)

Secondly, to push a NuGet Package, you can use this REST API:

Put https://[account].pkgs.visualstudio.com/_packaging/[feed id]/nuget/v2/

Simple steps for Postman:

  1. Using Get feeds/Get a feed REST API to get feed id
  2. Type above push package REST API URL and change request method to PUT
  3. Click Authorization tab
  4. Choose Basic Auth
  5. Leave Username to blank and type Personal Access Token to Password box
  6. Click Headers tab and add a new item (key: X-NuGet-ApiKey; value:VSTS)
  7. Click Body tab
  8. Choose form-data option
  9. Add a new Item: Select File option in Key box and click choose files button to select a nupkg file
  10. Click Send button and the response status result will be 202.

Regarding login page issue, it won't redirect to login page if current user is not authenticated when call REST API. You can authorize access to REST APIs with OAuth.

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • I want it to pull up the Microsoft Login page as it does when I load the Demo URL. The problem is that with the demo it works fine, and with my URL it gives a 401 instead of the login page. – Don Sartain Jun 19 '17 at 13:51
  • @DonSartain It won't redirect to the login page for authentication if call the REST API directly. You can authorize access to REST APIs with OAuth, for this way, it can redirect to login page. (check my update) – starian chen-MSFT Jun 20 '17 at 01:39
  • @DonSartain What's the result after trying OAuth? – starian chen-MSFT Jun 22 '17 at 02:02
  • I haven't been able to try it yet. But I didn't have to do anything special with the demo url, so I'm not sure why I would need to do OAuth just to get the login page that was returned by default from the demo url. – Don Sartain Jun 22 '17 at 02:09
  • @DonSartain I can't get the prompt window to login when using Postman with that url. There is a package that can prompt a login window and call REST API (do not include package REST API) https://www.nuget.org/packages/Microsoft.TeamFoundationServer.ExtendedClient/15.117.0-preview – starian chen-MSFT Jun 22 '17 at 02:52