Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with upgrading to @ewsjs/xhr from ews-javascript-api-auth #334

Closed
bladerunner2020 opened this issue Jan 13, 2020 · 11 comments · Fixed by #356
Closed

Issue with upgrading to @ewsjs/xhr from ews-javascript-api-auth #334

bladerunner2020 opened this issue Jan 13, 2020 · 11 comments · Fixed by #356
Milestone

Comments

@bladerunner2020
Copy link

Hello!
I am trying to upgrade to new helper library @ewsjs/xhr from ews-javascript-api-auth.

Original code that works:

ConfigurationApi.SetXHROptions({rejectUnauthorized : credentials.secure}); // global property
const exch = new ExchangeService(credentials.exchangeVersion);
exch.Credentials = new ExchangeCredentials(credentials.username, credentials.password);
exch.Url = new Uri(credentials.url);

const xhr = new ntlmAuthXhrApi(credentials.username, credentials.password, true);
exch.XHRApi  = xhr;

I replaced last 2 lines with:

const xhr = new XhrApi(true).useNtlmAuthentication(credentials.username, credentials.password);
exch.XHRApi  = xhr;

and got lot of warnings and error like this in dom-parse.js:

[xmldom error]	element parse error: Error: invalid tagName::]^�e��Sj�l 
[xmldom warning]	unclosed xml attribute 
[xmldom error]	element parse error: Error: invalid tagName:[^�{;�;����^����_ 
[xmldom warning]	attribute "ws}�nC�" missed value!! "ws}�nC�" instead2!! 

PS
Tried to use ConfigurationApi.ConfigureXHR(xhr) - with the same result.

Any ideas?

@RuckertSolutions
Copy link

Facing the same error, the responsetext of the xhrResponse in SimpleServiceRequestBase.InternalExecute are invalid chars.

@gautamsi
Copy link
Owner

I dont have access to ntlm server right now, but let me try restoring last one to check.

what version you are using for ews api and xhr?

@RuckertSolutions
Copy link

RuckertSolutions commented Jan 17, 2020

Hi gautamsi, I found the solution you described here.

Setting exch.AcceptGzipEncoding = false was fixing the problem for me. @bladerunner2020 give it a try

Edit:
"ews-javascript-api": "^0.10.0",
"@ewsjs/xhr": "^1.4.2",

@bladerunner2020
Copy link
Author

@Lumpenstein many thanks for link. I read the thread and found the solution.
I added gzip: true too XhrApi constructor:

const xhr = new XhrApi({ rejectUnauthorized: false, gzip: true }).useNtlmAuthentication(credentials.username, credentials.password);

PS
@gautamsi: I have 0.10.0 version for ewe-api and 1.4.2 for ewsjs/xhr

@gautamsi
Copy link
Owner

have you tried this:

Setting exch.AcceptGzipEncoding = false was fixing the problem for me. @bladerunner2020 give it a try

@bladerunner2020
Copy link
Author

Yeap. This also works.
I believe gzip:true is better )

have you tried this:

Setting exch.AcceptGzipEncoding = false was fixing the problem for me. @bladerunner2020 give it a try

@RuckertSolutions
Copy link

I believe gzip:true is better

True that :) haven't seen the gzip option there, because intellisense not working correclty for the request/request package

@gautamsi
Copy link
Owner

not all options of requestjs is added to typings that is why.

@RuckertSolutions
Copy link

Ah ok, I guess we can close this issue now, maybe add the gzip:true option to the readme for future users :)

@bladerunner2020
Copy link
Author

I don't mind. Still curious when this option is needed and when is not...

@gautamsi
Copy link
Owner

gautamsi commented Jun 7, 2020

added text in readme for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants