json-ld.org icon indicating copy to clipboard operation
json-ld.org copied to clipboard

Dereferencing a URL did not result in a valid JSON-LD object

Open pyrog opened this issue 5 years ago • 5 comments

All remote documents used display the following error:

jsonld.InvalidUrl: Dereferencing a URL did not result in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps due to a same-origin policy (ensure the server uses CORS if you are using client-side JavaScript), too many redirects, a non-JSON response, or more than one HTTP Link Header was provided for a remote context.

Example : https://mobilizon.chapril.org/events/ed969ea7-5c89-460e-b87b-6411ce747965

All tabs are empty, except the Visualized tab that display the graph. Expanded tab Vusalized tab

Tested with Safari, Chrome and Firefox

pyrog avatar Dec 16 '20 11:12 pyrog

Another example with data past from a webpage: same error message.

{

	"@context"				: "http://schema.org",
	"@type"					: "FoodEstablishment",
	
	"image": [
		
		"https://cdn.website.dish.co/media/62/04/2322328/Au-Cha-LHeureux-couv-cha.jpg"
	],
	
	"name"					: "Au Cha L'Heureux",
	"address"				: {
		"@type": "PostalAddress",
		"streetAddress": "3 Impasse du Miracle",
		"addressLocality": "Chavanod",
		"postalCode": "74650",
		"addressCountry": "FR"
	},
	"email"					: "",
	
	"menu"				: "https://cdn.website.dish.co/media/d5/b1/2385750/Au-Cha-LHeureux-menu-cha-lheureux.jpg",
	
	"priceRange": "",
	
	"geo"					: {
		"@context"				: "http://schema.org",
		"@type"					: "GeoCoordinates",
		"latitude"				: "45.8833524",
		"longitude"				: "6.0622454"
	},
	"url"					: "https://au-cha-lheureux-restaurant.eatbu.com/",
	"telephone"				: "+33450524233",
	"servesCuisine"			: "Française, Fait maison, Traditionnel",
	"paymentAccepted"		: "Espèces, Paiement sans contact, MasterCard, Ticket Restaurant®, VISA, Carte ticket restaurant, Carte de débit, Apple Pay",
	
	"openingHoursSpecification" : [
			
			{
			    "@type"		: "OpeningHoursSpecification",
			    "dayOfWeek"	: "http://schema.org/Monday",
			    "opens"		: "12:00",
			    "closes"	: "14:00"
			}
			,
		
			{
			    "@type"		: "OpeningHoursSpecification",
			    "dayOfWeek"	: "http://schema.org/Tuesday",
			    "opens"		: "12:00",
			    "closes"	: "14:00"
			}
			,
		
			{
			    "@type"		: "OpeningHoursSpecification",
			    "dayOfWeek"	: "http://schema.org/Wednesday",
			    "opens"		: "12:00",
			    "closes"	: "14:00"
			}
			,
		
			{
			    "@type"		: "OpeningHoursSpecification",
			    "dayOfWeek"	: "http://schema.org/Thursday",
			    "opens"		: "12:00",
			    "closes"	: "14:00"
			}
			,
			{
			    "@type"		: "OpeningHoursSpecification",
			    "dayOfWeek"	: "http://schema.org/Thursday",
			    "opens"		: "18:00",
			    "closes"	: "21:00"
			}
			,
		
			{
			    "@type"		: "OpeningHoursSpecification",
			    "dayOfWeek"	: "http://schema.org/Friday",
			    "opens"		: "12:00",
			    "closes"	: "14:00"
			}
			,
			{
			    "@type"		: "OpeningHoursSpecification",
			    "dayOfWeek"	: "http://schema.org/Friday",
			    "opens"		: "18:00",
			    "closes"	: "21:00"
			}
			,
		
			{
			    "@type"		: "OpeningHoursSpecification",
			    "dayOfWeek"	: "http://schema.org/Saturday",
			    "opens"		: "12:00",
			    "closes"	: "14:00"
			}
			,
			{
			    "@type"		: "OpeningHoursSpecification",
			    "dayOfWeek"	: "http://schema.org/Saturday",
			    "opens"		: "18:00",
			    "closes"	: "21:00"
			}
			,
		
			{
			    "@type"		: "OpeningHoursSpecification",
			    "dayOfWeek"	: "http://schema.org/Sunday",
			    "opens"		: "00:00",
			    "closes"	: "00:00"
			}
	
	],
	"specialOpeningHoursSpecification" : [
		
	]
		
	,"deliveryMethod": [
		
		"PICKUP",
		"DELIVERY"    	]
	
}

pyrog avatar Dec 16 '20 11:12 pyrog

It works with the Ruby distiller: http://rdf.greggkellogg.net/distiller?command=expand&format=jsonld&output_format=jsonld&url=https:%2F%2Fmobilizon.chapril.org%2Fevents%2Fed969ea7-5c89-460e-b87b-6411ce747965

as the error message indicated, it seems to most likely be a CORS issue.

gkellogg avatar Dec 16 '20 16:12 gkellogg

if you fix this issue of CORS error, please post it, i'm struggling with the same

luzlozanothermo avatar Feb 19 '21 01:02 luzlozanothermo

It's a server configuration issue. These are the headers returned from schema.org:

HTTP/2 200 
access-control-allow-credentials: true
access-control-allow-headers: Accept
access-control-allow-methods: GET
access-control-allow-origin: *
date: Fri, 19 Feb 2021 01:39:59 GMT
expires: Fri, 19 Feb 2021 01:49:59 GMT
etag: "v7F5aA"
x-cloud-trace-context: f8ad172246c779315ef4433df90888c6
content-type: application/ld+json
server: Google Frontend
content-length: 156492
cache-control: public, max-age=600
age: 0
alt-svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=

Key is probably access-control-allow-origin: *.

CORS was a bad idea, IMHO.

gkellogg avatar Feb 19 '21 01:02 gkellogg

@davidlehn thoughts?

gkellogg avatar Mar 21 '21 20:03 gkellogg