Nav 2018 Web service

suraj92291suraj92291 Posts: 43Member
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
“Any fool can know. The point is to understand.”
― Albert Einstein

Answers

  • RemkoDRemkoD Posts: 79Member
    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.
  • suraj92291suraj92291 Posts: 43Member
    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 Einstein
  • suraj92291suraj92291 Posts: 43Member
    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 Einstein
  • RemkoDRemkoD Posts: 79Member
    edited 2018-05-14
    The Same Origin Policy disallows reading the remote resource
    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).

    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 :)
Sign In or Register to comment.