Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Suggested answer

WEB API "msdyn_SearchResourceAvailability" returns outputs empty

(2) ShareShare
ReportReport
Posted on by 51

Hi,

I´m trying to schedule a resource for a work order (automatically) when a new resource requirement is created in my CRM organization. For this, I read about the ‘Search resource availability API’ and the most information that I found it was in these blogs:

Search Resource Availability with Universal Resource Scheduling API - Microsoft Dynamics 365 Blog

How to use the Search Resource Availability API - Universal Resource Scheduling - Microsoft Dynamics 365 Blog

I noticed that normally the people design a web resource through which they send the request for use this API, but I am not have experience working with this kind of solutions, so I prefer to use Power Automate to call the API through the unbound action: msdyn_SearchResourceAvailability.

I decided to start with a small number of parameters to verify this functionality, but no matter what parameters I test, the answer never shows me any available timeslot or resource. These are an example:

Imagen1.png

the flow's outputs give me resources and time slots empty as following:

3051.img2.png

but when I try to book a resource requirement in Field Service using the schedule assistant with the same duration and dates it show me the resources list.

What do you think i doing wrong? thanks

NOTE: When I try to put the "@odata.type" in power automate json, it give me a error. So I create a variable to solve this problem as saw in this site: Solved: Why does Compose Action give me an error? - Power Platform Community (microsoft.com)

  • philc79 Profile Picture
    philc79 90 on at
    RE: WEB API "msdyn_SearchResourceAvailability" returns outputs empty

    Not sure if you resolved this, I have had the same issue and I found the resolution in this article: www.praxiis.co.uk/.../fixing-the-search-resource-availability-api

  • srueda Profile Picture
    srueda 51 on at
    RE: WEB API "msdyn_SearchResourceAvailability" returns outputs empty

    Hi Gabriel,

    I had change the version to 2.1.1 on a HTTP request in Postman

    My HTML body is the following, similar to the Microsoft documentation example

    {
    
        "Version": "2.1.1",
    
        "IsWebApi": true,
    
        "Requirement": {
    
            "msdyn_fromdate": "2021-12-13",
    
            "msdyn_todate": "2021-12-17",
    
            "msdyn_remainingduration": 60,
    
            "msdyn_duration": 60,
    
            "@odata.type": "Microsoft.Dynamics.CRM.msdyn_resourcerequirement"
    
        },
    
        "Settings": {
    
            "ConsiderSlotsWithProposedBookings": false,
    
            "MovePastStartDateToCurrentDate": true,
    
            "@odata.type": "Microsoft.Dynamics.CRM.expando"
    
        },
    
        "ResourceSpecification": {
    
            "@odata.type": "Microsoft.Dynamics.CRM.expando",
    
            "ResourceTypes@odata.type": "Collection(Microsoft.Dynamics.CRM.expando)",
    
            "ResourceTypes": [
    
                {
    
                    "@odata.type": "Microsoft.Dynamics.CRM.expando",
    
                    "value": "3"
    
                }
    
            ]
    
        }
    
    }
    Captura3.PNG

    Now the API generate the following output, how can I fix this?

    {
        "@odata.context": "https://api.crm2.dynamics.com/api/data/v9.2/$metadata#Microsoft.Dynamics.CRM.msdyn_SearchResourceAvailabilityResponse",
        "TimeSlots": [
            {
                "@odata.type": "#Microsoft.Dynamics.CRM.organization"
            },
            {
                "@odata.type": "#Microsoft.Dynamics.CRM.organization"
            },
            {
                "@odata.type": "#Microsoft.Dynamics.CRM.organization"
            }
        ],
        "Resources": [
            {
                "@odata.type": "#Microsoft.Dynamics.CRM.organization"
            },
            {
                "@odata.type": "#Microsoft.Dynamics.CRM.organization"
            },
            {
                "@odata.type": "#Microsoft.Dynamics.CRM.organization"
            }
        ],
        "Related": {
            "@odata.type": "#Microsoft.Dynamics.CRM.organization"
        },
        "Exceptions": {
            "@odata.type": "#Microsoft.Dynamics.CRM.organization"
        }
    }

    Can you please share the HTML body you used the last time you built it the API?

    Thank you!

  • Suggested answer
    Gabriel Dias Junckes Profile Picture
    Gabriel Dias Junckes 2,428 on at
    RE: WEB API "msdyn_SearchResourceAvailability" returns outputs empty

    Hi.

    This API works well but it is hard to configure the first time. I will suggest you don't add many filters at the beginning before you get the results.

    I think the last time I built it, version 3.0 did not work so I user 2.0 or 2.1.1

    Regarding the  "@odata.type", you can try a compose function before or add a double @@ e.g.  "@@odata.type"

    I did not use the Dataverse action to do it before so I don't know it works. You can try to build it on the HTTP Request.

    powerusers.microsoft.com/.../921348

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans