<commit_before>
## WebAPI tutorial

## 1) CRM Web-API
The Web-API is promise based and will:
* Page (using @odata-nextLink)
* Use LogicalName(entityName) by finding correct entitySetName instead of LogicalName + 's'

### 1.1 Check WebApi support
The Web-API is new for Microsoft Dynamics 365 (online and on-premises).
See more about your Web-API version via CRM => Settings => Customizations => Developer Resources.
See more about Dynamics CRM Web API at https://msdn.microsoft.com/en-us/library/gg334767.aspx.

## 2) Include library
The WebAPI supports low-level requests. 
There is also a CRMSDK to support low- and high-level requests.
The library can be used via index.html or via modules. 
Besides the including, the usage of the library is equal for both index.html and module way of use. 

### 2.1) Index.html
Include the library in your index.html. The app.js is your own application code.
```html
<html>
<body>
    <script type="text/javascript" src="WebAPI.js"/>
    <script type="text/javascript" src="app.js"/>
</body>
</html>
```

In app.js, The WebAPI will be available on window scope. Example for using WebAPI below:
```javascript
//app.js
var WebAPI = window.WebAPI;

WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {
    //todo logic here 
});
```

### 2.2) Modules
The library can be imported or required. 
Using that means no include of the WebAPI.js in index.html is needed.
You only have to upload app.js to CRM instead of the WebAPI.js too.

#### 2.2.1) Example of ECMAScript 6.
```javascript
//app.js
import {WebAPI} from "../dist/WebAPI";

WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {
    //todo logic here 
});
```

#### 2.2.2) Example of require
```javascript
//app.js
var WebAPI = require("../dist/WebAPI.js"); //umd

WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {
    //todo logic here 
});
```

# 3) WebAPI
The WebAPI.js is the low level SDK for the CRM webApi.

## 3.1) Version
The default webApi version is 8.0, but you can change it runtime by setting the version.
```javascript
WebAPI.version = "8.2";
```

## 3.2) Create
The createEntity method has two parameters:
* logicalName
* attributes

```javascript
WebAPI.createEntity(logicalName, attributes).then(function (data) {});
```

```javascript
WebAPI.createEntity("account", {
    emailaddress1: "<EMAIL>" 
}).then(function (data) {});
```

## 3.3) Delete
The deleteEntity method has two parameters:
* logicalName
* entityId

```javascript
WebAPI.deleteEntity(logicalName, entityId).then(function (data) {});
```

```javascript
WebAPI.deleteEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function () {});
```

## 3.4) RetrieveEntity
The retrieveEntity method has three parameters:
* logicalName
* entityId
* queryOptions (odata query string)

```javascript
WebAPI.retrieveEntity(logicalName, entityId, queryOptions).then(function (data) {});
```

```javascript
WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function () {});
```

## 3.5) RetrieveEntitySet
This class is used by retrieveEntity after finding the entitySetName
and can be used when entitySetName is known already.
The retrieveEntitySet method has three parameters:
* entitySetName
* entityId
* queryOptions (odata query string)

```javascript
WebAPI.retrieveEntitySet(entitySetName, entityId, queryOptions).then(function (data) {});
```

```javascript
WebAPI.retrieveEntitySet("accounts", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {});
```

## 3.6) RetrieveMultiple
The retrieveMultiple method has two parameters:
* logicalName
* queryOptions (odata query string)

```javascript
WebAPI.retrieveMultiple(logicalName, queryOptions).then(function (data) {});
```
<commit_msg>Small fixes.<commit_after>
## WebAPI tutorial

## 1) CRM Web-API
The Web-API is promise based and will:
* Page (using @odata-nextLink)
* Use LogicalName(entityName) by finding correct entitySetName instead of LogicalName + 's'

### 1.1 Check WebApi support
The Web-API is new for Microsoft Dynamics 365 (online and on-premises).
See more about your Web-API version via CRM => Settings => Customizations => Developer Resources.
See more about Dynamics CRM Web API at https://msdn.microsoft.com/en-us/library/gg334767.aspx.

## 2) Include library
The WebAPI supports low-level requests. 
There is also a CRMSDK to support low- and high-level requests.
The library can be used via index.html or via modules. 
Besides the including, the usage of the library is equal for both index.html and module way of use. 

### 2.1) Index.html
Include the library in your index.html. The app.js is your own application code.
```html
<html>
<body>
    <script type="text/javascript" src="WebAPI.js"/>
    <script type="text/javascript" src="app.js"/>
</body>
</html>
```

In app.js, The WebAPI will be available on window scope. Example for using WebAPI below:
```javascript
//app.js
var WebAPI = window.WebAPI;

WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {
    //todo logic here 
});
```

### 2.2) Modules
The library can be imported or required. 
Using that means no include of the WebAPI.js in index.html is needed.
You only have to upload app.js to CRM instead of the WebAPI.js too.

#### 2.2.1) Example of ECMAScript 6.
```javascript
//app.js
import {WebAPI} from "../dist/WebAPI";

WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {
    //todo logic here 
});
```

#### 2.2.2) Example of require
```javascript
//app.js
var WebAPI = require("../dist/WebAPI.js"); //umd

WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {
    //todo logic here 
});
```

# 3) WebAPI
The WebAPI.js is the low level SDK for the CRM webApi.

## 3.1) Version
The default webApi version is 8.0, but you can change it runtime by setting the version.
```javascript
WebAPI.version = "8.2";
```

## 3.2) Create
The createEntity method has two parameters:
* logicalName
* attributes

```javascript
WebAPI.createEntity(logicalName, attributes).then(function (data) {});
```

```javascript
WebAPI.createEntity("account", {
    emailaddress1: "<EMAIL>" 
}).then(function (data) {});
```

## 3.3) Delete
The deleteEntity method has two parameters:
* logicalName
* entityId

```javascript
WebAPI.deleteEntity(logicalName, entityId).then(function (data) {});
```

```javascript
WebAPI.deleteEntity("account", "475b158c-541c-e511-80d3-<KEY>").then(function (data) {});
```

## 3.4) RetrieveEntity
The retrieveEntity method has three parameters:
* logicalName
* entityId
* queryOptions (odata query string)

```javascript
WebAPI.retrieveEntity(logicalName, entityId, queryOptions).then(function (data) {});
```

```javascript
WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {});
```

## 3.5) RetrieveEntitySet
This class is used by retrieveEntity after finding the entitySetName
and can be used when entitySetName is known already.
The retrieveEntitySet method has three parameters:
* entitySetName
* entityId
* queryOptions (odata query string)

```javascript
WebAPI.retrieveEntitySet(entitySetName, entityId, queryOptions).then(function (data) {});
```

```javascript
WebAPI.retrieveEntitySet("accounts", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {});
```

## 3.6) RetrieveMultiple
The retrieveMultiple method has two parameters:
* logicalName
* queryOptions (odata query string)

```javascript
WebAPI.retrieveMultiple(logicalName, queryOptions).then(function (data) {});
```

{'fraction_non_alphanumeric': 0.13699165797705945, 'fraction_numerical': 0.045881126173096975, 'mean_word_length': 4.870696250956389, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 24, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3561527', 'n_tokens_mistral': 2736, 'n_tokens_neox': 2460, 'n_words': 763}