Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : YB85b+tKjR7Crrdbx6Npyy
Microsoft Dynamics CRM (Archived)

JavaScript "Failed to load resource: the server responded with a status of 404 (Not Found)"

Like (0) ShareShare
ReportReport
Posted on 31 Aug 2015 17:35:54 by

Hi everyone,

Thank you for helping in advance,

I got an error when debugging my JavaScript code

"Failed to load resource: the server responded with a status of 404 (Not Found)"

on the line: "xmlHttpRequest.send();"

full code:

 executeRequest: function (request) {
        var xmlHttpRequest = new XMLHttpRequest();
        var response = null;
        xmlHttpRequest.open("GET", OrgDataService.getRESTUrl() + request, false);
        xmlHttpRequest.setRequestHeader("Accept", "application/json");
        xmlHttpRequest.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        xmlHttpRequest.send();
        return xmlHttpRequest.responseText;
    },

    getRESTUrl: function () {
        var serverUrl = Xrm.Page.context.getClientUrl();
        return serverUrl.substring(serverUrl.lastIndexOf("/")) + "/xrmservices/2011/organizationdata.svc";
    }

Thank you again!

*This post is locked for comments

  • Prashnat Verma Profile Picture
    287 on 11 Jul 2018 at 07:33:06
    RE: JavaScript "Failed to load resource: the server responded with a status of 404 (Not Found)"

    Hi @sartraj,

    I am also facing the same issue,may I please know what you exactly passing in your Odata_query?

    Thanks

    Prashant Verma

  • Goloknath Profile Picture
    on 01 Sep 2015 at 19:38:50
    RE: JavaScript "Failed to load resource: the server responded with a status of 404 (Not Found)"

    thank you for your code!

  • Goloknath Profile Picture
    on 01 Sep 2015 at 19:38:33
    RE: JavaScript "Failed to load resource: the server responded with a status of 404 (Not Found)"

    thank you for your reply!

  • ScottDurow Profile Picture
    19 on 31 Aug 2015 at 18:08:42
    RE: JavaScript "Failed to load resource: the server responded with a status of 404 (Not Found)"

    I suggest installing www.fiddler2.com and looking at the request that is being sent and causing the 404 - it is most likely to be that you have the incorrect entity set name - e.g. it should be AccountSet for accounts.

  • Verified answer
    Sartaj Profile Picture
    880 on 31 Aug 2015 at 17:59:26
    RE: JavaScript "Failed to load resource: the server responded with a status of 404 (Not Found)"

    Hi Chris,

    Try the below code, just pass the Odata query which you want to execute to the method and get back the result.

    function ODataCall(oData_query)
    {
        var _result = null;
        var _serverUrl = Xrm.Page.context.getClientUrl();
        var _oDataSelect = _serverUrl + "/XRMServices/2011/OrganizationData.svc/" + oData_query;

        var _retrieveReq = new XMLHttpRequest();
        _retrieveReq.open("GET", _oDataSelect, false);
        _retrieveReq.setRequestHeader("Accept", "application/json");
        _retrieveReq.setRequestHeader("Content-Type", "application/json;charset=utf-8");

        _retrieveReq.onreadystatechange = function ()
        {

            if (_retrieveReq.readyState == 4) {
                if (_retrieveReq.status == 200) {
                    var _retrieved = JSON.parse(_retrieveReq.responseText).d;
                    if (_retrieved.results.length > 0) {
                        _result = _retrieved.results[0];
                    }
                }
            }
        };
        _retrieveReq.send();
        return _result;
    }

    Let me know if you are still not able to perform Odata call, thanks.

    Sartaj

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,727 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,714 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading started