Senaite Json API - update Sample Analyses

How can update et set sample analyses using JSON API

Tried to do like :

net_mass_setup = "http://localhost:8080/senaite/@@API/senaite/v1/update/df4583b53fc842ecaa2140c4d7652603"

data = {
    'Result': '0.7555',
    'Uncertainty': '0.0003927',  
}


update_response = ses.post(net_mass_setup, json=data)

if update_response.status_code == 200:
    print(f"Update successful: {update_response.json()}")
else:
    print(f"Update failed with status code: {update_response.status_code}")
    print(update_response.text)

Nothing works

Hi Tim,
is the session ses authenticated?

I’ve resolved this problem by

ms = 'http://localhost:8080/senaite/@@API/senaite/v1/update/0186670016a94e14b2e1ce2375289685'


data = {

            'Result': '0.475', 
            'Uncertainty': '0.000500'

}
update_ms = ses.post(ms, json=data).json()
for item in update_ms['items']:
    print(item['Result'])
    print(item['Uncertainty'])

now it works

1 Like