Ajax request not working with Google files (solved)

0 favourites
  • 5 posts
From the Asset Store
Google Analytics 4 Plugin for Construct 3 enables metrics and analytics for your games easily.
  • Hi!

    Few months ago, I made a project that reads csv data from a google sheet file, using Ajax: request URL. Everything was working fine, project closed. Yesterday, I re-opened it but Ajax request is not working any more. Is it working for you or should I fill a bug report?

    Here is a simplified .c3p file for testing:

    https://drive.google.com/file/d/1ZUt6Q77UqVXOBeprR4px-emjxJYagks3/view?usp=sharing

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I can't open your project, please bundle the CSV2Array addon with it.

    You can press F12 in preview and check error messages in the console log.

  • I had "Bundle Addons" checked. I don't know why it asks for the addon...

    Anyway. I removed the addon, you can open it now..

    Thank you very much for your interest.

    Console says: "...... has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."

  • CORS is the most common error with AJAX. Try searching this forum, I've seen dozens of posts about it..

  • You can change CORS Policy when the file is uploaded on your server.. but what happens when you use a google sheet file?

    Google has changed CORS Policy (due to security reasons) and you cannot open files using other programs, anymore.

    I found a solution for anyone who is interested in:

    The link we were using in order to open a csv file was something like this:

    https://docs.google.com/spreadsheets/d/e/.../pub?output=csv

    In order to bypass cors policy and open your csv file, the link should be in this format:

    https://docs.google.com/spreadsheets/d/SHEET_KEY/gviz/tq?tqx=out:csv&sheet=SHEET_NAME

    * You can find the sheet key by opening your sheet file in google drive

    https://docs.google.com/spreadsheets/d/SHEET_KEY/edit#gid=0

    ** SHEET_NAME, not your file's name

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)