XMLHttpRequest NETWORK_ERR

XMLHttpRequest NETWORK_ERR

Anonymous
Not applicable
1,265 Views
10 Replies
Message 1 of 11

XMLHttpRequest NETWORK_ERR

Anonymous
Not applicable

I have a library script that makes an XMLHttpRequest to a REST API.  The script works fine if I set the XMLHttpRequest URL to http://myapi.foo.com, but when I try to change the request to https://myapi.foo.com (notice the s in https), the script fails with a NETWORK_ERR and no additional error information.  I am able to execute the same request from Chrome developer tools and Firefox developer tools using the https URL without issue.  Has anyone else encountered this issue?  Are there any other ways to make an HTTPS request in PLM Scripting?

 

Failing Script:

var APIURL = "https://myapi.foo.com";
var xhr = new XMLHttpRequest();
xhr.open('PUT',APIURL);
xhr.send(); // fails here
var response = xhr.responseText;

Successful Script:

var APIURL = "http://myapi.foo.com";
var xhr = new XMLHttpRequest();
xhr.open('PUT',APIURL);
xhr.send();
var response = xhr.responseText;

Thanks!

0 Likes
1,266 Views
10 Replies
Replies (10)
Message 2 of 11

gasevsm
Alumni
Alumni
Hi,
If you take he https:// route via manual browser typing in, does it stay https or it redirects to http protocol?

Martin Gasevski | Fusion 360 Team Product Manager
0 Likes
Message 3 of 11

Anonymous
Not applicable

Hi Martin,

 

I just performed this in Chrome, and it in fact the request stays https and even shows that the TLS/SSL certificate is valid and trusted.  I was able to get a little more error information from the error log attached to my script.  The full error is: [XMLHttpRequest] org.mozilla.javascript.JavaScriptException: NETWORK_ERR.

0 Likes
Message 4 of 11

tony.mandatori
Autodesk
Autodesk

Your browser might have certificates that are not installed on the server.

 

The only way to diagnose is for someone with access to the server to run the following

 

openssl s_client -showcerts -connect myapp.foo.com:443

 

I don't have access to the server.

0 Likes
Message 5 of 11

gasevsm
Alumni
Alumni
We don't install certs on server. Something else may be going on here. This should work both https and http. I'll do some tests and share..

Martin Gasevski | Fusion 360 Team Product Manager
0 Likes
Message 6 of 11

Anonymous
Not applicable

Thanks for your help Martin!  It's greatly appreciated.  The https://myapi.foo.com is obviously a fictitious URL, but I can provide you with my actual API URL on a private thread if it helps you to diagnose this issue.

0 Likes
Message 7 of 11

dany.poudrier
Alumni
Alumni

Hi,

 

We have a few customers running into similar situations and posted on this Forum:

 

http://forums.autodesk.com/t5/fusion-lifecycle-forum/xmlhttprequest-in-action-script/m-p/4378373/hig... : Authentication required since it is a secured channel.

 

http://forums.autodesk.com/t5/fusion-lifecycle-forum/javascript-require-method/m-p/6388586/highlight... : Signed certificate issue

 

http://forums.autodesk.com/t5/fusion-lifecycle-forum/network-err-for-xlmhttprequest-in-a-script/m-p/... : Authentification should be encoded 

 

 

From your snipplet, it seems that you didn't include the Authentication information in the request. If you tested with chrome you may have an active session already running.  I suggest that you open a new Chrome in Incognito mode and try again the https and analyse the response.

 



Dany Poudrier

PLM Product Manager
0 Likes
Message 8 of 11

Anonymous
Not applicable

Hi Dany,

 

Thank you for the recommendations.  I have unfortunately viewed all of the forum threads that you reference, and they do not address the issue that i'm encountering.  The API URL that i'm trying to access is a RESTful service that we developed in house.  The service does not currently require authentication or an Authorization header of any kind.  Additionally, the service is stateless, so no sessions are created and Chrome would not have an auth session associated with this API.  We are able to successfully access this service from other environments without issue.

 

It would be great if the PLM scripting debugger provided a more verbose error message.  We aren't sure how to proceed at this point because the error message is so generic (NETWORK_ERR).

0 Likes
Message 9 of 11

gasevsm
Alumni
Alumni
I'm looking into this with assistance of Autodesk Cloud OPS. Thanks for your patience,

Martin Gasevski | Fusion 360 Team Product Manager
Message 10 of 11

Anonymous
Not applicable

Thank you for your assistance with this.  I believe the issue was actually caused by my third party hosting provider for my external API.  I was able to resolve by moving my API to a different host.

0 Likes
Message 11 of 11

gasevsm
Alumni
Alumni
Pleasure. Very glad you found a solution.

Martin Gasevski | Fusion 360 Team Product Manager
0 Likes