Page 1 of 1

Use JSON API for get/post/put kvp?

PostPosted: Fri Dec 21, 2018 4:01 pm
by DaveMellert
Hello everyone, the subject line is pretty self explanatory. Can I use the JSON API to look at and update map annotations? I would prefer that to using the Python API for what I am trying to do, but if that is not implemented I may have no other choice.

Re: Use JSON API for get/post/put kvp?

PostPosted: Thu Jan 03, 2019 11:27 am
by manics
Hi Dave

The JSON API doesn't support map-annotations: https://github.com/openmicroscopy/openm ... pi/urls.py

This is clearly something that would be useful so I'll add a feature request.

Note the webclient has a method to allow map-annotations in the client namespace to be modified. If you're interested in adding support to the JSON API yourself this might help:
- https://github.com/openmicroscopy/openm ... s.py#L2259
- https://github.com/openmicroscopy/openm ... ls.py#L221

Simon

Re: Use JSON API for get/post/put kvp?

PostPosted: Fri Jan 11, 2019 8:52 pm
by DaveMellert
Thanks for adding the feature request! It would be a big help for us. We want to be able to link our various databases through metadata and the JSON API is much handier in terms of integrating with our various other systems than the Python API, which requires OMERO.py and ICE.

I would take a crack at adding support myself but I am quite a novice compared to others in this group and am rather overburdened at the moment. But I love the idea of contributing to the user community and hopefully I can get to that point soon!

Re: Use JSON API for get/post/put kvp?

PostPosted: Mon Jan 14, 2019 10:05 am
by wmoore
Hi Dave,

You should be able to use the 'webclient' JSON api.
This is what the webclient uses internally, so we don't document it or test it independently of webclient and in theory it's more likely to change on a minor release than the documented API.
But you can get map annotations for 1 or more objects, e.g. image, well, or dataset via:

Code: Select all
/webclient/api/annotations/?type=map&image=3125701&image=3125703


For example, take a look at http://idr.openmicroscopy.org/webclient ... ge=3125703

To create a map annotation on an Image, you can POST to:

Code: Select all
/webclient/annotate_map/


with JSON content such as:

Code: Select all
{
    image: 4420,
    mapAnnotation: [["siRNAi","Aurora-B"],["test","edit"]]
}


To edit an existing annotation, also include
Code: Select all
annId: 123
. This will replace existing Key-Value pairs with the list supplied.

Hope that helps.

Will.

Re: Use JSON API for get/post/put kvp?

PostPosted: Mon Jan 14, 2019 2:54 pm
by DaveMellert
Thanks Will, I'll try that. How would I specify the namespace using this method?

Re: Use JSON API for get/post/put kvp?

PostPosted: Tue Jan 15, 2019 9:59 am
by wmoore
Hi,

I'm afraid that the namespace is always set to 'client namespace' which is what the webclient uses to indicate that Map Annotations were created by the webclient (or Insight) so they should be editable in the clients.
This is an obvious example of this api being internal to the webclient and not 'general purpose'.

You can see the code for this at:
https://github.com/openmicroscopy/openm ... s.py#L2290

You can see that the fix would be pretty trivial (check if request.POST.get('ns') is not None and use that value).
However, I don't think we are planning to release any functionality changes in OMERO in the near future.

Will

Re: Use JSON API for get/post/put kvp?

PostPosted: Tue Jan 15, 2019 2:31 pm
by wmoore
I opened a PR with the change needed to support namespace https://github.com/openmicroscopy/openm ... /pull/5940
but I don't know if/when this will get merged and released.

Regards,
Will.

Re: Use JSON API for get/post/put kvp?

PostPosted: Wed Jan 16, 2019 10:38 pm
by DaveMellert
Thank you so much for your help! I think I have some good options here for what I need to do.