I am working on Senaite API to send the request based on Client Order Number.
I am using the following get method URL to pull the details for a particular Client Order Number.
The above URL returns all the available Analysis Request in the system. But, I want to get only one Analysis Request where my Client Order Number is linked.
First, note that objects from type âAnalysisRequestâ are stored in a catalog other than âbika_setup_catalogâ. You can check the catalogs a given portal type is stored by using the âcatalogsâ resource: Catalog resource at senaite.jsonapi documentation
If you use the catalogs resource, youâll see that the main catalog where objects from type âAnalysisRequestâ are stored is called âbika_catalog_analysisrequest_listingâ. Again, if you inspect the indexes (for searching and sorting) of this catalog, youâll find there is no index available for ClientOrderNumber. There are other indexes available though, like getClientSampleID. Therefore, you cannot do direct searches by âClientOrderNumberâ. However, if there is no choice and you need to do searches against this field, you can either
a) add an index (with name getClientOrderNumber and type FieldIndex) through ZMI to this catalog or
b) create a new catalog with your own indexes and metadata columns.
Remember that on both cases youâll need to force the reindex the index via ZMI afterwards. If you follow the strategy (a), you will then be able to retrieve all the objects with a request like follows:
Thank you for your reply. Its really helpful. I understand ClientOrderNumber is not in index. But when I try to use getClientSampleID, I get the response but it returns all the Analyst Request available in the system.
URL
I expect, the API should return only the ID for the related Sample Id, but instead it displays everything.
Moreover, as per the documentation if I search as follows it should display information about the catalogs registered in the system, as well as the indexes and metadata fields (schema) they contain:
v1/catalogs
But instead it displays as follows
{
â_runtimeâ: 0.0028390884399414062,
âmessageâ: âNot Foundâ,
âsuccessâ: false
}
Is there any problem in my environment or Do you have any idea? It would be really helpful if you shed light on this.
Thank You
I have updated the version to 1.2.3. The search functionality is working fine now. I created a custom index and able to fetch the records. Now, I am trying to create a Sample via API.
/senaite/@@API/senaite/v1/AnalysisRequest/create/eaa740b037f84e4b8b9aebad696dbc17
But, I am getting the below error message
{
â_runtimeâ: 0.04502296447753906,
âmessageâ: ââNoneTypeâ object has no attribute âgetPrefixââ,
âsuccessâ: false
}
Do you have any idea to fix this? Thank you for your help.
Thank you for your input Jordi. I am am able to create the samples via API. But, the sample id becomes 33 chars. I have raised this issue as a separate question in the forum. Thank you.