XRM-OSS / Xrm-WebApi-Client

A promise-based JavaScript library for the Microsoft Dynamics CRM WebApi - TypeScript type definitions available
https://xrm-oss.github.io/Xrm-WebApi-Client/
MIT License
100 stars 28 forks source link

Dynamics 9.0 changes JSON response format, breaks decoding payload #31

Closed jlaurila closed 6 years ago

jlaurila commented 6 years ago

https://github.com/DigitalFlow/Xrm-WebApi-Client/blob/040b255be0312efa1ba0a8e176eb1d94d77f5820/src/js/WebApiClient.Response.js#L15

this should be changed to less strict regexp about whitespace: ^{[\s\S]*?(?=})}

8.2 format: { "@odata.context":".....","value":[ ] }

9.0 format: {"@odata.context":".....","value":[]}

other similar changes are possible and should be checked.

DigitalFlow commented 6 years ago

Hi @jlaurila,

Thanks for reporting, I'll fix it as soon as possible.

Kind Regards, Florian

DigitalFlow commented 6 years ago

Hi @jlaurila,

Unfortunately your suggested regex broke the unit tests, as pre 9.0 regexes will not be matched properly anymore. I'll work on an expression that works for both versions.

Kind Regards, Florian

jlaurila commented 6 years ago

Yeah, I noticed the same. I made a hotfix with this regexp /^{[\s\S]*}/m which is naive but seems to work with unit tests and 9.0. Didn't try with 8.x. Thanks for looking into this.

DigitalFlow commented 6 years ago

Hey @jlaurila,

sorry for the late response, I was lacking a development org (and time). I looked into it right now and your last regex seems to do the trick. I just applied it and published it as v3.6.11, can you give it a try? Thanks in advance.

Kind Regards, Florian