From the examples I have found searching through the Senaite Community, it seems that the only fields that can be given values through the ‘/AnalysisRequest/create’ API call are: Contact, DateSampled, SampleType, and Template. Is this the case or can all the fields from the ‘Request new analyses’ page in Senaite be given values through the above call?
Also, I’ve found the recipe to create new columns for a sample listing, but is it possible to create new fields for sample creation to correspond to new columns added to the listing?
My intent is to add custom fields/columns and be able to assign values to them upon sample creation through the API call.
I would appreciate any insight you may have. Thank you for your time.
From the examples I have found searching through the Senaite Community, it seems that the only fields that can be given values through the ‘/AnalysisRequest/create’ API call are: Contact, DateSampled, SampleType, and Template. Is this the case or can all the fields from the ‘Request new analyses’ page in Senaite be given values through the above call?
Values from other existing fields passed through the POST payload on sample (aka “AnalysisRequest”) creation should be processed as usual (as long as they are valid values). You can see in the code that the creation of this type of object ultimately rely on the same function as if you were submititng the Sample Add form: senaite.jsonapi/src/senaite/jsonapi/api.py at 1.x · senaite/senaite.jsonapi · GitHub (note data parameter is the dict of key:value)
Also, I’ve found the recipe to create new columns for a sample listing, but is it possible to create new fields for sample creation to correspond to new columns added to the listing?
I am most interested in assigning Lab Analyses. I tried a workaround by adding a ‘Template’ (which was created in Senaite with analyses attached) to samples through the above call. However, unlike assigning a Sample Template through the Sample Add form in Senaite itself, assigning one through the jsonapi call did not allow for the Lab Analyses within the Sample Template to show up when the new sample is viewed in Senaite.