This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

REST-API Object ID

Hello,

I need some advice on how to properly write the command using REST-API to get all objects having an ID between, for example, 100 and 200.

I know how to get all objects of type 102: /REST/objects/102

I also know how to get all object of type 102 having property 20 (Created) later than January 1st: /REST/objects/102?p20>>=2023-01-01

But I don't know how to get all objects of type 102 having an ID between 100 and 200.

Thanks.

Martin Leclerc

Parents
  • Hello Craig,

    Thanks for your reply.

    Actually, I need to retrieve properties for all objects of type 102.   But since the number of objects is about 4000 and the practical limit is 500 records, I need to do segmentations. I thought that using Object ID as the 'bucket' would be a good way to do that.

    Thanks for your support.

    Martin Leclerc

  • So.  A couple of things.

    The default limit is 500, but your code can request a larger number (Searching using the M-Files Web Service (REST API)).  It still may be limited by the server, though, depending upon a number of factors.  This may be a good quick option for you.

    If you were using the COM API then I'd guide you down the "segmented search" route, which does exactly what you're talking about (the fact you use the word "segments" makes me think you've come across this already): MFilesSamplesAndLibraries/Samples/COM API/SegmentedSearch at master · M-Files/MFilesSamplesAndLibraries (github.com)

    Unfortunately the segmented search relies upon the object ID which, again, I assume you've found, there isn't a documented REST API search parameter for.

    There are a couple of options:

    1. There is an undocumented (therefore theoretically unsupported) querystring parameter that you can send named "i".  This is the object ID.  It works in the same way as others, so you can restrict the search results by the ID and grab objects 1=>100, 101->200, etc..
    2. You could consider exposing a "vault extension method" and calling that via the REST API.  This vault extension method can take whatever data you want (it's a string) and return whatever data you want (it's a string).  This way you could actually define a method that does exactly what you need and only return exactly what you need.

    I include number 1 above as an option, but it's not one I would really recommend.  I know that the querystring parameter is used by some integrations, but in theory it's not supported and may change in the future.  It's unlikely, but hopefully you understand why I have to say that.

    Number 2 is probably what I would guide you towards, especially if the logic on what to retrieve is more complex (e.g. you only need certain properties).  This gives you complete control over what you do in the method and the data that's returned back out again.  However: it requires you to have some code in the vault (VBScript or, probably vastly better here, VAF).

  • Hello Craig.

    Thank again for your reply.

    Yes, I did come across the segmented search route.

    The parameter I is indeed working but it seems that I can't combine them in the url like

    /REST/objects/102?I>>=4000&I<<4100.   That returns all ObjectId higher than 4000.  Is there a way to combine two parameters? 

    I will check VAF, I guess the best way to start is here: https://developer.m-files.com/Frameworks/Vault-Application-Framework/ , right?

    Thanks for your support!

    Martin Leclerc

Reply Children