Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Error while Invoking Action from JavaScript "Resource not found for the segment"

$
0
0

Hi, I am trying to Invoke an Action from JavaScript. But getting the following error message:

Resource not found for the segment Microsoft.Dynamics.CRM.abc_CreateRecurringPaymentRequests

Code is as Below:

function handleRecurringPaymentRequest() {
    var functionName = "abc_CreateRecurringPaymentRequests";
    var quoteId = Xrm.Page.data.entity.getId();
    quoteId = quoteId.replace(/[{}]/g, "");
    var result;

    try {
        var query = "quotes(" + quoteId + ")/Microsoft.Dynamics.CRM." + functionName;
        var clientUrl = Xrm.Page.context.getClientUrl();
        var req = new XMLHttpRequest();
        req.open("POST", clientUrl + "/api/data/v9.1/" + query, true);
        req.setRequestHeader("Accept", "application/json");
        req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        req.setRequestHeader("OData-MaxVersion", "4.0");
        req.setRequestHeader("OData-Version", "4.0");

        req.onreadystatechange = function () {

            if (this.readyState == 4 /* complete */) {
                req.onreadystatechange = null;

                if (this.status == 200) {
                    //success callback
                    result = JSON.parse(this.response);
                } else {
                    //error callback
                    var error = JSON.parse(this.response).error;
                    alert(error.message);
                }
        }
};
req.send();

} catch (e) {
    alert(e.message);
}

alert(result.newRprUrl);
}

I have checked using the link below and Action is available in metadata:

https://myorgname.crm4.dynamics.com/api/data/v9.1/$metadata


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images