Thanks so much Brian for your detailed answer, thanks to you I'm starting to understand something !
Viviana
________________________________ Da: Mediawiki-api mediawiki-api-bounces@lists.wikimedia.org per conto di mediawiki-api-request@lists.wikimedia.org mediawiki-api-request@lists.wikimedia.org Inviato: domenica 29 aprile 2018 14:00 A: mediawiki-api@lists.wikimedia.org Oggetto: Mediawiki-api Digest, Vol 129, Issue 2
Send Mediawiki-api mailing list submissions to mediawiki-api@lists.wikimedia.org
To subscribe or unsubscribe via the World Wide Web, visit https://lists.wikimedia.org/mailman/listinfo/mediawiki-api or, via email, send a message with subject or body 'help' to mediawiki-api-request@lists.wikimedia.org
You can reach the person managing the list at mediawiki-api-owner@lists.wikimedia.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Mediawiki-api digest..."
Today's Topics:
1. Wikimedia API redirect 301 (viviana paga) 2. Re: Wikimedia API redirect 301 (bawolff)
----------------------------------------------------------------------
Message: 1 Date: Sat, 28 Apr 2018 14:33:29 +0000 From: viviana paga viviana.paga@hotmail.it To: "mediawiki-api@lists.wikimedia.org" mediawiki-api@lists.wikimedia.org Subject: [Mediawiki-api] Wikimedia API redirect 301 Message-ID: DB6PR06MB3128D1B493601C07A5FF46C5E48C0@DB6PR06MB3128.eurprd06.prod.outlook.com
Content-Type: text/plain; charset="windows-1252"
Hi everyone,
I'm developing an Ajax webservice that query Wikimedia Api Service, but I get a very strange behavior; in fact my query sometimes works perfectly and sometimes doesn't work at all (301 internal redirect) .
This is the response by the server: X-Cors-Redirect-1: 301 https://commons.wikimedia.%E2%80%A6metadata&sroffset=0&callback=?
Could you help me to understand why or what I miss in my code?
This is my code :
$.ajaxPrefilter(function (options) { if (options.crossDomain && jQuery.support.cors) { const https = (window.location.protocol === 'http:' ? 'http:' : 'https:'); options.url = https + '//cors-anywhere.herokuapp.com/' + options.url; } if ( !options.beforeSend) { options.beforeSend = function (xhr) { xhr.setRequestHeader('Api-User-Agent', 'OpenArtImages/Beta (http://localhost:8080; viviana.paga@hotmail.it; Wikipedia User: Vivsss)'); xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); xhr.setRequestHeader('Origin', 'http://localhost:8080'); xhr.setRequestHeader('Strict-Transport-Security', 'max-age=106384710; includeSubDomains; preload');
xhr.withCredentials = true; } } });
firstRequest = $.get( 'https://commons.wikipedia.org/w/api.php?origin=*&action=query&list=s... &prop=imageinfo|pageids|titles&srnamespace=6&rawcontinue=&srinfo=totalhits|suggestion&srlimit='+limit+'&iiprop=timestamp|user|url|size|sha1|mime|metadata'+offset+'&callback=?', function (response) { ///// ........ I get Data ......... ///// }
Thank you so much, Viviana Paga