Skip to content

Commit a1efac2

Browse files
add: remove brackets from a guid value in @odata.bind navigation property association
1 parent a29a4c5 commit a1efac2

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,8 @@ dynamicsWebApi.executeUnboundAction("WinOpportunity", actionRequest).then(functi
861861

862862
### In Progress
863863

864-
- [ ] overloaded functions with rich request options for all Web API operations.
865864
- [X] get all pages requests, such as: countAll, retrieveMultipleAll, fetchXmlAll and etc. Implemented in v.1.2.5.
865+
- [ ] overloaded functions with rich request options for all Web API operations.
866866
- [ ] "formatted" values in responses. For instance: Web API splits information about lookup fields into separate properties, the config option "formatted" will enable developers to retrieve all information about such fields in a single requests and access it through DynamicsWebApi custom response objects.
867867
- [ ] Intellisense for request objects.
868868

lib/requests/sendRequest.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,17 @@ module.exports = function sendRequest(method, uri, config, data, additionalHeade
2424
if (data) {
2525
stringifiedData = JSON.stringify(data, function (key, value) {
2626
/// <param name="key" type="String">Description</param>
27-
if (key.endsWith("@odata.bind") && typeof value === "string" && !value.startsWith(config.webApiUrl)) {
28-
value = config.webApiUrl + value;
27+
if (key.endsWith("@odata.bind")) {
28+
if (typeof value === "string") {
29+
//remove brackets in guid
30+
if (/\(\{[\w\d-]+\}\)/g.test(value)){
31+
value = value.replace(/(.+)\(\{([\w\d-]+)\}\)/g, '$1($2)');
32+
}
33+
//add full web api url if it's not set
34+
if (!value.startsWith(config.webApiUrl)) {
35+
value = config.webApiUrl + value;
36+
}
37+
}
2938
}
3039

3140
return value;

0 commit comments

Comments
 (0)