Unexpected end of JSON input

I try to show mediawiki API inside Snap! but get a message 'Unexpected end of JSON input"

The request is:
/w/api.php?action=query&format=json&prop=info&titles=Albert%20Einstein

The answer:
{"batchcomplete":"","query":{"pages":{"736":{"pageid":736,"ns":0,"title":"Albert Einstein","contentmodel":"wikitext","pagelanguage":"en","pagelanguagehtmlcode":"en","pagelanguagedir":"ltr","touched":"2023-09-11T08:49:29Z","lastrevid":1174741664,"length":234555}}}}

It worked for me

It works if you put the plain text to Split() But if you give Spit URL() it return error

It's a CORS issue. Getting access to the data from other websites is no longer possible without the explicit permission of that site. There were plenty of threads about the CORS proxy.

There is also Manual:CORS - MediaWiki
It requires specifying additional headers "origin", "mode" with the "Web Services Access" library.

EDIT. "origin=*" should work as well
https://www.mediawiki.org/w/api.php?action=query&format=json&prop=info&titles=Albert%20Einstein&origin=*


but still "missing" status ;(

May be it is possibe to use Web Services Library for the same purpose? But I can't find any lessons or example with Web Services Library - How to use header and which of them suitable for wikipedia and other mediawiki sites
Thanks @dardoro for help

My wiki http://digida.mgpu.ru/

CORS usage

The MediaWiki API requires that the origin be supplied as a query string parameter, with the value being the site from which the request originates, which is matched against the Origin header required by the CORS protocol

Only origin=* works for me...

https://www.mediawiki.org/w/api.php?action=query&format=json&prop=info&titles=Albert%20Einstein&origin=*

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.