Book Image

Microsoft Dynamics 365 Extensions Cookbook

Book Image

Microsoft Dynamics 365 Extensions Cookbook

Overview of this book

Microsoft Dynamics 365 is a powerful tool. It has many unique features that empower organisations to bridge common business challenges and technology pitfalls that would usually hinder the adoption of a CRM solution. This book sets out to enable you to harness the power of Dynamics 365 and cater to your unique circumstances. We start this book with a no-code configuration chapter and explain the schema, fields, and forms modeling techniques. We then move on to server-side and client-side custom code extensions. Next, you will see how best to integrate Dynamics 365 in a DevOps pipeline to package and deploy your extensions to the various SDLC environments. This book also covers modern libraries and integration patterns that can be used with Dynamics 365 (Angular, 3 tiers, and many others). Finally, we end by highlighting some of the powerful extensions available. Throughout we explain a range of design patterns and techniques that can be used to enhance your code quality; the aim is that you will learn to write enterprise-scale quality code.
Table of Contents (19 chapters)
Title Page
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Using Cross-Origin Resource Sharing with CRM Online


Using the Dynamics 365 web API within Dynamics 365 web resources is straightforward. We previously covered a web API in a few recipes; (Querying 365 data using the Web API endpoint and Building custom UI using Angular recipes of Chapter 2, Client-Side Extensions, and Connecting to Dynamics 365 from other systems OData (Java) recipes of Chapter 5, External Integration); however, accessing the web API from the client side on a different web application is a bit more challenging.

If you simply create a request using XMLHttpRequest from a locally hosted web application to the web API, you will receive the following error:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 401. 

An unauthorized 401 exception is returned due to missing authentication details. In this recipe, we will build a single-page HTML application (SPA) with...