Receive Sample and add to Worksheet using JSON API

So far I have been able grab a list of all sample points in a client, and create 1 new AR for each, then create a new batch and add all of these to the new batch.

Is it possible to mark these samples as received (from their UID), and add to a new Worksheet using the JSON API?

Regarding the received transition, you can make use of the do_action_for function from JSON API: https://github.com/senaite/senaite.core/blob/master/bika/lims/jsonapi/doactionfor.py#L45

Not sure about how you can add analyses to a worksheet (worksheet.addAnalysis function) using the JSON API Update call (https://github.com/senaite/senaite.core/blob/master/bika/lims/jsonapi/update.py#L44)… I think it is not implemented and mimic all the addAnalysis process will be tedious and tricky.

Have you considered extending the JSON functionality through a custom addon?

Hi @kiwi3007 and @Espurna,

I am also trying to update the “review_status” of a sample through the JSON API. I manage to create users, samples etc using the API but I am confused by the use of the ‘do_action_for’ function. Would it be possible to get an example of its use?

Best,

T

Hi there,

sorry for multiple postings but I found the solution to my issue with:
curl --request POST
–url

http://192.168.0.1:1234/senaite/@@API/senaite/v1/update/sampleUID
–header ‘content-type: application/json’
–cookie __ac=%22NjE2NDZkNjk2ZTo2MTY0NmQ2OTZl%22
–data ‘{
“Client”:clientUID,
“transition”:“receive”
}’

Cheers

1 Like