ERROR - API syntax for /firmware/actions/upgrade

Hi, I got a problem with firmware upgrade through API. I need help with syntax (at least I think that it is syntax, still new to this).
Here is the code I need help with:

url_firmUpg = f"{baseUrl}/firmware/actions/upgrade"
header_firmUpg = {“Authorization”: f"Bearer {token}"}
data_firmUpg = {“keep_settings”: “true”}
response_firmUpg = requests.post(url=url_firmUpg,
headers=header_firmUpg,
json=data_firmUpg)

image

This is the error message:
{‘success’: False, ‘errors’: [{‘source’: ‘Validation’, ‘code’: 102, ‘error’: ‘No arguments provided for action’, ‘section’: ‘upgrade’}]}

I know that I am missing something but I can’t find what, even on Teltonika Networks website under firmware/actions/upgrade there is only this:

{
    "data": {
        "keep_settings": "string"
    }
}

Thanks in advance for your help.

You need to add the data object as described in the documentation. The correct POST json should be:

data_firmUpg = {"data": {"keep_settings": "1"}}

Thanks for reply, but even with this it doesn’t work. This time when you change it to this:
image

I get this error:
{‘success’: False, ‘errors’: [{‘source’: ‘JSON body’, ‘code’: 122, ‘error’: ‘unexpected character’}]}

(if you change “1” to “true” it’s the same)

Ok I found what I did wrong, I used in: “requests.post(url=…, header=…, data=data_firmUpg)”, but I needed to change “data” to “json” like this: “requests.post(url=…, header=…, json=data_firmUpg)”

pwsh thanks for the help with this :heart:

1 Like

This topic was automatically closed 40 hours after the last reply. New replies are no longer allowed.