Cannot update LABORATORY INFORMATION using senaite.jsonapi

I am trying to update the LABORATORY INFORMATION configuration using the senaite.jsonapi. The response status is 400, and the response text is {"_runtime": 0.011113166809082031, “message”: “No Objects could be updated”, “success”: false}. I am having success creating other config items, such as LAB CONTACTS, LAB DEPARTMENTS, etc., but I can’t seem to update the LABORATORY INFORMATION values. Any ideas why?

Thanks!

After searching the online documentation, I believe that the LABORATORY INFORMATION cannot be updated using the api, because the container for Laboratory is ‘/senaite/bika_setup’.

According to the documentation…

SENAITE.JSONAPI does not allow the update of objects when:

  • the container is the portal root (senaite path)
  • the container is senaite’s setup (senaite/bika_setup path)

per…
https://senaitejsonapi.readthedocs.io/en/latest/crud.html#update

So, if this is true, and if it applies to LABORATORY INFORMATION, I guess we cannot update it using the api.

If anyone has any information to the contrary, and LABORATORY INFORMATION is updatable using the api, please let me know.

Thank you !

Hi @dtaph

  1. You need a function that posts the requested data e.g. create function:
requests.post(API_URL+"/create", headers=headers, json=data, auth=AUTH)
API_URL = "http://" + ip + ":" + port + "/" + "senaite" + "/@@API/senaite/v1/"
  1. You need to create the site e.g.
data = [
        ('site_id', SITE_ID),
        ('title', 'SENAITE'),
        ('default_language', 'en'),
        ('extension_ids:list', 'plonetheme.classic:default'),
        ('extension_ids:list', 'plonetheme.sunburst:default'),
        ('extension_ids:list', 'senaite.lims:default'),
        ('form.submitted:boolean', 'True'),
        ('submit', 'Install SENAITE LIMS'),
    ]

    requests.Session().post(BASE_URL + "/@@senaite-addsite",
                            data=data, auth=("admin", "admin"))
  1. Create something e.g. LAB DEPARTMENT
data = {"portal_type": "Department",
            "title": "Microbiology",
            "DepartmentID": "DEP-01",
            "Manager": client_contact_uid,
            "parent_path": "/" + SITE_ID + "/bika_setup/bika_departments"}
    lab_department_uid = create(data)

Hi albionshala,

Thank you for the response. I have been able to create departments without issues, using the API. I have also been able to create other configuration items with the API. I only have issues with the LABORATORY INFORMATION, and I believe that it is because it lies in a path that is restricted…

SENAITE.JSONAPI does not allow the update of objects when:

  • the container is the portal root (senaite path)
  • the container is senaite’s setup (senaite/bika_setup path)

per…
[CRUD — senaite.jsonapi 1.2.5 documentation]

So, I will just update this manually.

Thanks again for your input !

1 Like

I am sorry for misunderstanding the question.
Yes, the bika_setup cannot be updated via API, the way I do it is usually via updating the files manually as you’ve suggested.

Good luck!

Thanks again - I appreciate your support, and willingness to help :+1: