Using API to perform Major Update / Upgrade

Started by carrot, January 07, 2021, 03:34:38 PM

Previous topic - Next topic
Hi everyone

I'm struggling to find a way to perform a Major update (e.g. from 19.1 to 19.7) using the API.  Is there anyone who has successfully done this using the API or other programmatic method?

January 07, 2021, 04:43:29 PM #1 Last Edit: February 04, 2021, 05:39:26 PM by carrot
I found the answer to make it go via cmd:
sudo --user=nobody  /usr/local/sbin/configctl firmware auto-update ALLOW_RISKY_MAJOR_UPGRADE


Here is the Powershell version (including ignoring ssl error)

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

$user = 'APIKEY'
$pass = 'APISECRET'

$pair = "$($user):$($pass)"

$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))

$basicAuthValue = "Basic $encodedCreds"

$Headers = @{
    Authorization = $basicAuthValue
}

$URL = "https://IPOFROUTER/api/core/firmware/upgrade"
Invoke-WebRequest -uri $url -method post -Headers $Headers -Body '{"upgrade":"maj"}' -ContentType "application/json"