Nav 2018 Web service
suraj92291
Member Posts: 49
Hello experts,
im trying to access nav 2018 codeunit web service from android/php (which env is on different server) but keep getting error
" Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 401."
any help would be greatly apprecited
sam
im trying to access nav 2018 codeunit web service from android/php (which env is on different server) but keep getting error
" Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 401."
any help would be greatly apprecited
sam
“Any fool can know. The point is to understand.”
― Albert Einstein
― Albert Einstein
0
Answers
-
Just to rule things out. Have you've tried to access the NAV webservice on the android/php machine through a web browser or something? Do you get the WSDL page?
If that is working I would expect that you have to fix the issue on the request side. The code that is making the request package that is send to the NAV app server.0 -
Im able to call it from PHP/c# but its giving same error for android ionic framework..
sam“Any fool can know. The point is to understand.”
― Albert Einstein0 -
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/
soapjs.php:41:12
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://111.111.11.111:11111/NAV2018/WS/SystemService. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).“Any fool can know. The point is to understand.”
― Albert Einstein0 -
To me this looks like that the request is blocked from the site you're developing that launches the request to the NAV webserver. I think your webserver is configured to only access sources from localhost and not from remote servers (your Dynamics NAV server).The Same Origin Policy disallows reading the remote resource
More information about Access-Control-Allow-Origin. You can configure the webserver to allow resources from another origin/server. You can also test if this is the issue by including this into the header from your PHP script.
Anyway I doubt this is a Dynamics NAV Webservice issue. You might as well try other forums
0 -
The only enpoint in NAV which allows CORS requests are the new api page:
https://docs.microsoft.com/en-us/dynamics-nav/endpoints-apis-for-dynamics
https://forum.mibuso.com/discussion/71245/odata-api-page-with-cross-origin-requests#latest0 -
> @suraj92291 said:
> Hello experts,
>
> im trying to access nav 2018 codeunit web service from android/php (which env is on different server) but keep getting error
>
> " Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 401."
>
> any help would be greatly apprecited
>
> sam
Hi Sam, I had the exact same issue with Ionic/Javascript AJAX soap call. It looks like a direct connection to the exposed codeunit isn't supported as you can't set the CORs header/method in the NST config. I went back to the proxy method, made a C# ASMX web service that wraps the NAV gateway function. I let the ASMX handle the authentication.
Also in IIS for the proxy I set the CORs properties (Origin/Method etc.). This isn't a great solution as I'd ideally wanted to rule out using a proxy due to non on premise customers (D365 BC) but what can you do?
Anyway give me a shout if you want the code snippets, happy to share the Ajax / ASMX if it helps.
Cheers Andy, Dionix0 -
Hi Andy,
Can you share your Ajax / ASMX solution ?0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions