Hello, I’m trying to use the new octopus cli to create and publish a nuget package to the Octopus Built-in Package Repository.
I’m doing this from a mac, running version 1.2.1 of the octopus cli.
I first ran octopus package nuget create, answered all of the prompts, and got a .nupkg file (attached). I then tried to upload it by running octopus package upload and I get the following error message
Failed to upload package canto-dmc_tumult_octotest-alpha.1.1.2.nupkg - invalid character '<' looking for beginning of value
invalid character '<' looking for beginning of value
I suspect the HTTP request is not responding with JSON as expected, but with an HTML error page, but the actual HTTP response isn’t output by the cli, so I can’t see what the actual error was.
What’s odd is I can upload the exact same .nupkg file via the Octopus web UI and it works without issue. The Octopus API key I’m using belongs to the same user I’m logging into the web application with, so I don’t think it’s a permissions issue.
Thanks for reaching out and I’m sorry you’re having issues uploading via the CLI.
Typically when we see this particular error it’s usually HTML headers as you suspect. Most of the time these come from proxies or webapp-level firewalls, as Octopus itself typically doesn’t return API calls (which is what our CLI uses) with anything but JSON.
Since the upload is working for the UI, is it possible that you have Octopus itself configured to go through a proxy but the CLI tool is using machine settings that might not have a proxy configured? I say proxy here but it could be a few different devices.
Otherwise, you might be able to use a script to simulate the API call but still leave the test outside of the Octopus UI itself. Hopefully running a script will give you a more verbose error.
The script helped me figure this out. The source of the issue was my octopus config had the url set to ‘http://myproject.octopus.app’ instead of ‘https://myproject.octopus.app’. When doing CLI commands like octopus project list it worked fine with http. Presumably, the HTTP client in the CLI was following redirects automatically for GET requests and not POST requests, which is why things errored out on uploading a package.
In any event, I managed to solve the issue. Thanks so much for the prompt help!
I appreciate you letting us know you got unstuck here. That’s interesting that redirect behavior is different between calls; I wouldn’t have guessed that. This should be useful information for anyone in the future as well.
Please don’t hesitate to reach out if you have any further issues or questions.