API task options with booleans

I have a small problem. I am submitting new tasks via API. I use this recipe

options = json.dumps([
    {'name': "orthophoto-resolution", 'value': 24}
])

res = requests.post('http://localhost:8000/api/projects/{}/tasks/'.format(project_id), 
            headers={'Authorization': 'JWT {}'.format(token)},
            files=images,
            data={
                'options': options
            }).json()

task_id = res['id']

If I add an option that is a boolean and set it to false, the options are not accepted (True does work!)
For instance:

options = json.dumps([
    {'name': "dsm", 'value': False}
])

res = requests.post('http://localhost:8000/api/projects/{}/tasks/'.format(project_id), 
            headers={'Authorization': 'JWT {}'.format(token)},
            files=images,
            data={
                'options': options
            }).json()

task_id = res['id']

Does anyone know what the problem is?

1 Like

I think that for “false” options they default to false, so not passing them should be the same as setting them “false” explicitly.

This would then mirror the behavior of the local script/py/cmd.

Hey Saijin, thanks for your idea. I just checked and wow…indeed it seems that they all default to False! That should solve it, thanks! Strange still why explicitly setting it to False would not work.

1 Like

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