Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

SendEmail Web API ERRORS: "No HTTP resource was found that matches the request URI" and "')' or ',' expected at position..."

(0) ShareShare
ReportReport
Posted on by 279

I'm trying to create an Email record and then send it using JS. Here is a portion of my code:

    Xrm.WebApi.createRecord("email", data).then(

        function success(result) {
            var emailId = result.id;
            emailId = emailId.substring(1,emailId.length-1);

            window.parentFormContext.getAttribute("new_giresponseemail").setValue("/emails("   emailId   ")");

            var url = 'https://ORGNAME.crm.dynamics.com/api/data/v9.1/emails('   emailId   ')/Microsoft.Dynamics.CRM.SendEmail';

            var body = JSON.stringify({
                "IssueSend": "true"
            });

            var req = new XMLHttpRequest();
            req.open("POST", url, true);
            req.setRequestHeader('Content-Type', 'application/json');
            req.send(body);

            Xrm.Utility.showProgressIndicator("Please wait a moment...");
            
            req.onreadystatechange = function () {
                Xrm.Utility.closeProgressIndicator();    
                
                if (this.readyState === 4) { 
                    
                    req.onreadystatechange = null;
                
                    if (this.status === 200) {
                        var result = "Response successfully sent!"; 
                        alert(result); 
                    }
                    else if(this.status === 400){
                        var result = "ERROR: Please contact your CRM administrator."; 
                        alert(result);
                    }
                }
            }  
        },

        function (error) {
            console.log(error.message);
        }
    )

This creates the email record correctly. However, when the XMLHTTPRequest is opened I'm getting a 400 response with the error message "')' or ',' expected at position 4 in (GUID)" for the API action. Sometimes the "position" number is different depending on the GUID that was generated for the new email record.

If I enter the API URL in the browser manually I get this error: "No HTTP resource was found that matches the request URI '">ORGNAME.crm.dynamics.com/.../Microsoft.Dynamics.CRM.SendEmail'."

I've scoured the internet trying to find a solution for this but no luck. Thanks for any help!

  • Lucas H Profile Picture
    Lucas H 279 on at
    RE: SendEmail Web API ERRORS: "No HTTP resource was found that matches the request URI" and "')' or ',' expected at position..."

    Thank you SO MUCH! This worked perfectly. Glad the fix was so simple but wish I'd asked before spending a couple hours frantically Googling...

  • Suggested answer
    Charan Raju C R Profile Picture
    Charan Raju C R 7 Super User 2024 Season 1 on at
    RE: SendEmail Web API ERRORS: "No HTTP resource was found that matches the request URI" and "')' or ',' expected at position..."

    Hi Lucas,

    Take out or comment line #5: emailId = emailId.substring(1,emailId.length-1); 

    Id of the result (email) is not enclosed within '{' and '}'. So, this line is not required as trimming is not necessary. 

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