web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

cross domain web api call from CRM using JavaScript

(0) ShareShare
ReportReport
Posted on by 94

i want to validate address for that i have made web api call onsave.

wen i call to cross domain api for validate data at that time i am facing below issue.

Access to fetch at 'api.easypost.com/.../addresses' from origin 'toastmastersdevtrng.crm.dynamics.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

working fine in postman.

my code is below.

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("authorization", "Basic ---------------------");
myHeaders.append("crossDomain", "true");
myHeaders.append("Access-Control-Allow-Origin", "">devtrng.crm.dynamics.com/");
myHeaders.append("Access-Control-Allow-Credentials", "true");
myHeaders.append("Access-Control-Allow-Methods", "POST");
myHeaders.append("Access-Control-Allow-Headers", "Overwrite, Destination, Content-Type, Depth, User-Agent, Translate, Range, Content-Range, Timeout, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control, Location, Lock-Token,DAV, content-length, Allow");
myHeaders.append("Access-Control-Max-Age", "3600");

var raw = JSON.stringify({"street1":"9127 S Jamaica St","street2":"","city":"Englewood","state":"CO","zip":"80112","country":"United States","verify":["delivery"]});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("">api.easypost.com/.../addresses", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Please help to archive this.

Thanks in advance!!

I have the same question (0)
  • Suggested answer
    NODAL Profile Picture
    860 on at

    Hi Maulik,

    D365 actually does not allow calls to cross domain APIs, you have following alternatives.

    1)Plugin/Custom workflow

    2)PCF control

    Thanks,

    Ketan

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    Check below article which is implemented for CRM 2013. But you can try in your instance to check it if works.

    xrmdynamicscrm.wordpress.com/.../

    Please mark my answer verified if i were helpful

  • Maulik Lakhani Profile Picture
    94 on at

    doesn`t help..

  • Maulik Lakhani Profile Picture
    94 on at

    We need to verify api response with user before record going to save so any best option?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 171 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 83

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans