locked
Retreiving information of multiple entities by passing entity ids in the query string RRS feed

  • Question

  • My trying to get information of all the entities by passing all the entity ids in my query

    [Organization URI]/api/data/v8.2/accounts?$filter=contains(entity_id,'562d9d8b-f51e-4089-8fab-9f3ab7255a28') or contains(entity_id,'1b884e0f-fb11-4b9e-aaae-84f4114db514') or contains(entity_id,'426a4bbe-b66a-42ee-864a-647b9f860d7e')

    or

    [Organization URI]/api/data/v8.2/accounts(562d9d8b-f51e-4089-8fab-9f3ab7255a28,1b884e0f-fb11-4b9e-aaae-84f4114db514,426a4bbe-b66a-42ee-864a-647b9f860d7e)

    Reference: https://msdn.microsoft.com/en-us/library/gg334767.aspx

    Both these options are returning me Status Code: 400 or Bad request.

    What is wrong with this or what is a better way to do this?



    • Edited by Manvir Kaur Tuesday, March 14, 2017 5:46 AM
    Monday, March 13, 2017 12:10 PM

Answers

  • I am able to get my data using this :

    [Organization URI]/api/data/v8.1/accounts?$filter=entity_id eq C0088EEF-3BD3-E611-80EA-FC15B4280D0C or entity_id eq 717CE9CA-7E6C-E611-80DD-FC15B428DEEC or entity_id eq 10632443-7F6C-E611-80DD-FC15B428DEEC or entity_id eq 77E4FC91-7F6C-E611-80DD-FC15B428DEEC or entity_id eq DC848EE9-A06E-E611-80DB-C4346BB59860

    I got to know that contains does not work with guid comparisons. So I used eq which worked. Limitation with query builder for me was that I don't have direct access of CRM but it was a nice option.

    Thank you for your response @RhettClinton

    • Marked as answer by Manvir Kaur Tuesday, March 14, 2017 6:07 PM
    Tuesday, March 14, 2017 6:06 PM

All replies

  • You can only use a single id in the way you are using accounts(Guid). If you want to retrieve based on more then one then you need to use the filter option.

    You might find it useful to use this tool for constructing REST queries against the WEBApi https://crmrestbuilder.codeplex.com/


    MS CRM Bing'd - http://bingsoft.wordpress.com
    Dynamics XRM Tools CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM 2011 OData Query Designer
    CRM 2013 Quick View Menu

    Monday, March 13, 2017 10:42 PM
    Moderator
  • Yes I tried following query also

    [Organization URI]/api/data/v8.2/accounts?$filter=contains(entity_id,'562d9d8b-f51e-4089-8fab-9f3ab7255a28') or contains(entity_id,'1b884e0f-fb11-4b9e-aaae-84f4114db514') or contains(entity_id,'426a4bbe-b66a-42ee-864a-647b9f860d7e')

    This also seems to be not working for me.

    Tuesday, March 14, 2017 5:55 AM
  • I am able to get my data using this :

    [Organization URI]/api/data/v8.1/accounts?$filter=entity_id eq C0088EEF-3BD3-E611-80EA-FC15B4280D0C or entity_id eq 717CE9CA-7E6C-E611-80DD-FC15B428DEEC or entity_id eq 10632443-7F6C-E611-80DD-FC15B428DEEC or entity_id eq 77E4FC91-7F6C-E611-80DD-FC15B428DEEC or entity_id eq DC848EE9-A06E-E611-80DB-C4346BB59860

    I got to know that contains does not work with guid comparisons. So I used eq which worked. Limitation with query builder for me was that I don't have direct access of CRM but it was a nice option.

    Thank you for your response @RhettClinton

    • Marked as answer by Manvir Kaur Tuesday, March 14, 2017 6:07 PM
    Tuesday, March 14, 2017 6:06 PM