0

I'm trying to retrieve linked data from an endpoint which is secured. I've used the same credentials and configuration variables which successfully return results in YASGUI gives an error in Python. The error is: EndPointInternalError: endpoint returned code 500 and response.

The code is:

import rdflib
from SPARQLWrapper import SPARQLWrapper, JSON, POST, BASIC, DIGEST, XML

sparql = SPARQLWrapper("")
sparql.setHTTPAuth(BASIC)
sparql.setCredentials("user","pwd")
sparql.setMethod(POST)
sparql.setQuery("""
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX base: <https://w3id.org/def/basicsemantics-owl#>
    PREFIX sh: <http://www.w3.org/ns/shacl#>
    PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
    PREFIX owl: <http://www.w3.org/2002/07/owl#>
    SELECT ?subject ?subject_label ?aspect ?aspect_label
    WHERE
    {
    ?subject rdfs:subClassOf/owl:onProperty ?aspect .
    ?subject skos:prefLabel ?subject_label .
    ?aspect skos:prefLabel ?aspect_label .
    }
""")    
sparql.setReturnFormat(JSON)
results = sparql.query().convert()

print(results)

I've used Fiddler to trace the call. It seems the underlying problem has something to do with certificates. The error currently is: URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)>. Googled here and there and it is suggested that I should run a Python install certificates.command. However, this is not available in my Python folder. I'm using Python 3.8

Sef
  • 85
  • 7
  • Am I missing something - where do you set the endpoint URL? Have you tried tracing what is send to the endpoint using a proxy like Telerik Fiddler? Which line is the error at? Please edit the full error message into your question. – DisappointedByUnaccountableMod Dec 02 '20 at 22:06
  • which endpoint is used here? – UninformedUser Dec 03 '20 at 06:52
  • I've used Fiddler to trace the call. It seems the underlying problem has something to do with certificates. The error currently is: URLError: . Googled here and there and it is suggested that I should run a Python install certificates.command. However, this is not available in my Python folder. I'm using Python 3.8. – Sef Dec 03 '20 at 07:22

1 Answers1

0

An HTTP error of 500 means the server is failing.

The common response message is "Internal Server Error".

It's not the caller's fault.

Roughly:

4xx - client at fault
5xx - server at fault

AndyS
  • 16,345
  • 17
  • 21