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!

    API key for package promotion

    Scheduled Pinned Locked Moved Support
    promotionsproget
    5 Posts 2 Posters 66 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.
    • ? This user is from outside of this forum
      Guest
      last edited by

      Hi

      We recently upgraded to Proget 4.6.7 from an older version, and wanted to test out the package promoting API in our pipeline. We tried following the example from the documentation, but all we get is the following message: An API key is required to promote packages.

      We have set up an API key with access to the package promotion API, and we tried it out with the /api/promotions/list endpoint, which worked. But the documentation does not specify how the API key should be included in the POST request for /api/promotions/promote. Adding it to the URL, like in the list example, does not work. Could you clarify how we should do this?

      Product: ProGet
      Version: 4.6.7

      1 Reply Last reply Reply Quote 0
      • ? This user is from outside of this forum
        Guest
        last edited by

        Hmm... looks like that is only documented for the BuildMaster and Otter APIs... I'll put a note in to add that for the ProGet docs too, thanks!

        Here are the supported ways to supply the API key:

        • Request header (X-ApiKey) - all content types
        • Querystring value (key) - all content types
        • Form value (key) - only application/x-www-form-urlencoded content type
        • JSON property (API_Key) on root object - only application/json content type
        1 Reply Last reply Reply Quote 1
        • ? This user is from outside of this forum
          Guest
          last edited by

          We tried this, with moderate success.

          The Querystring option does not seem to work at all (this is what we initially tried, based on the list example). This is what it looks like in the Proget log:

          Date	                API Key	        Request URL	                        Response Code
          08.02.2017 10:29:36	(not specified)	/api/promotions/promote?key=xxxx...	403
          

          By the way, why can I not upload images directly? That would make this a lot simpler.

          We also had trouble using the JSON property, at least from .NET. We set up a request using HttpClient, with the following result in the Proget log:

          Date	                API Key	        Request URL	                Response Code
          08.02.2017 10:46:10	(not specified)	/api/promotions/promote  	403
          

          However, sending a POST request with Postman using exactly the same body (containing the API key) worked just fine. It looks like this has something to do with the content encoding. When using HttpClient, we set the charset to utf-8, which is the standard for JSON encoding, but in Postman, this is not explicitly set by default. If we set charset to utf-8 in Postman, the request fails there too, with the same response: An API key is required to promote packages.

          The request header (X-ApiKey) method seems to work with respect to supplying the API key, but Proget does not seem to parse the rest of the content correctly: Specified from feed '' does not exist.

          Again, this works if we send the POST request with Postman without setting charset, so it is likely the same problem as above.

          My question is: which charset does Proget expect for the content in the POST request, if not the default utc-8?

          1 Reply Last reply Reply Quote 0
          • ? This user is from outside of this forum
            Guest
            last edited by

            Thank you for the additional information; this is a bug in the Content-Type handing. The problem stems from the JSON parsing for the API key to be exactly application/json without any charset info, though utf-8 would be correct otherwise. We've modified the handler to resolve this, and it will be included in the next maintenance release (or if we forego that, the next minor release) due out end of this week or early next week.

            D 1 Reply Last reply Reply Quote 0
            • D Offline
              dac_4595 @Guest
              last edited by

              Thanks for this post id did help me a lot. I did also get the message "Specified from feed '' does not exist." while trying package promotion. This message is missleading as the real issue was the http Client not passing all the content types as the server wanted. I did try with postman and powershell Invoke-WebRequest.
              Think the server is unecessary strict with handling the requests, but maybe there is a reason for that.
              Please consider adding a few "HttpClient" example to the documentation in different languages like powershell, java,c#. It would save the customer a lot of time.
              https://docs.inedo.com/docs/proget/reference/api/package-promotion

              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