We're Hiring!

Use JSON API for get/post/put kvp?

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Use JSON API for get/post/put kvp?

Postby DaveMellert » Fri Dec 21, 2018 4:01 pm

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.
DaveMellert
 
Posts: 21
Joined: Mon Jun 04, 2018 5:46 pm

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

Postby manics » Thu Jan 03, 2019 11:27 am

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
User avatar
manics
Team Member
 
Posts: 261
Joined: Mon Oct 08, 2012 11:01 am
Location: Dundee

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

Postby DaveMellert » Fri Jan 11, 2019 8:52 pm

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!
DaveMellert
 
Posts: 21
Joined: Mon Jun 04, 2018 5:46 pm

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

Postby wmoore » Mon Jan 14, 2019 10:05 am

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.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

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

Postby DaveMellert » Mon Jan 14, 2019 2:54 pm

Thanks Will, I'll try that. How would I specify the namespace using this method?
DaveMellert
 
Posts: 21
Joined: Mon Jun 04, 2018 5:46 pm

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

Postby wmoore » Tue Jan 15, 2019 9:59 am

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
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

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

Postby wmoore » Tue Jan 15, 2019 2:31 pm

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.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

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

Postby DaveMellert » Wed Jan 16, 2019 10:38 pm

Thank you so much for your help! I think I have some good options here for what I need to do.
DaveMellert
 
Posts: 21
Joined: Mon Jun 04, 2018 5:46 pm


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest