Could not retrieve a JSON-LD document from the URL

Hi

I could not issue the certification with Blockerts V3 from cert-tool.

When I run this command, I got the error below.

python3 cert_issuer -c conf_ethtest.ini

i suspect that this problem is because of pyld as you can see the link below.

https://github.com/digitalbazaar/pyld/issues/133

Does anyone help me?? This is the whole log.

bash-4.3# python3 cert_issuer -c conf_ethtest.ini
WARNING - Your app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
INFO - This run will try to issue on the ethereum_ropsten chain
INFO - Set cost constants to recommended_gas_price=20000000000.000000, recommended_gas_limit=25000.000000
INFO - Processing 1 certificates
INFO - Processing 1 certificates under work path=/cert-issuer/data/work
INFO - Balance check response: {'jsonrpc': '2.0', 'id': 1, 'result': '0x1b6a4d3f1bcbc000'}
INFO - Balance check succeeded: {'jsonrpc': '2.0', 'id': 1, 'result': '0x1b6a4d3f1bcbc000'}
INFO - Total cost will be 500000000000000 wei
INFO - Starting finalizable signer
WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
INFO - Stopping finalizable signer
WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 6595, in load_document
    if (remote_doc['contentType'] == 'text/html' or
KeyError: 'contentType'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 145, in _fetch_context
    requestProfile='http://www.w3.org/ns/json-ld#context')
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 6617, in load_document
    cause=cause)
pyld.jsonld.JsonLdError: ('Could not retrieve a JSON-LD document from the URL.',)
Type: jsonld.LoadDocumentError
Code: loading document failed
Details: {'remoteDoc': {'contextUrl': None, 'documentUrl': 'https://www.w3.org/ns/odrl.jsonld', 'document': '{\n "@context": {\n    "odrl":    "http://www.w3.org/ns/odrl/2/",\n    "rdf":     "http://www.w3.org/1999/02/22-rdf-syntax-ns#",\n    "rdfs":    "http://www.w3.org/2000/01/rdf-schema#",\n    "owl":     "http://www.w3.org/2002/07/owl#",\n    "skos":    "http://www.w3.org/2004/02/skos/core#",\n    "dct":     "http://purl.org/dc/terms/",\n    "xsd":     "http://www.w3.org/2001/XMLSchema#",\n    "vcard":   "http://www.w3.org/2006/vcard/ns#",\n    "foaf":    "http://xmlns.com/foaf/0.1/",\n    "schema":  "http://schema.org/",\n    "cc":      "http://creativecommons.org/ns#",\n\n    "uid":     "@id",\n    "type":    "@type",\n\n    "Policy":           "odrl:Policy",\n    "Rule":             "odrl:Rule",\n    "profile":          {"@type": "@id", "@id": "odrl:profile"},\n\n    "inheritFrom":      {"@type": "@id", "@id": "odrl:inheritFrom"},\n\n    "ConflictTerm":     "odrl:ConflictTerm",\n    "conflict":         {"@type": "@vocab", "@id": "odrl:conflict"},\n    "perm":             "odrl:perm",\n    "prohibit":         "odrl:prohibit",\n    "invalid":          "odrl:invalid",\n\n    "Agreement":           "odrl:Agreement",\n    "Assertion":           "odrl:Assertion",\n    "Offer":               "odrl:Offer",\n    "Privacy":             "odrl:Privacy",\n    "Request":             "odrl:Request",\n    "Set":                 "odrl:Set",\n    "Ticket":              "odrl:Ticket",\n\n    "Asset":               "odrl:Asset",\n    "AssetCollection":     "odrl:AssetCollection",\n    "relation":            {"@type": "@id", "@id": "odrl:relation"},\n    "hasPolicy":           {"@type": "@id", "@id": "odrl:hasPolicy"},\n\n    "target":             {"@type": "@id", "@id": "odrl:target"},\n    "output":             {"@type": "@id", "@id": "odrl:output"},\n    \n    "partOf":            {"@type": "@id", "@id": "odrl:partOf"},\n\t"source":            {"@type": "@id", "@id": "odrl:source"},\n\n    "Party":              "odrl:Party",\n    "PartyCollection":    "odrl:PartyCollection",\n    "function":           {"@type": "@vocab", "@id": "odrl:function"},\n    "PartyScope":         "odrl:PartyScope",\n\n    "assignee":             {"@type": "@id", "@id": "odrl:assignee"},\n    "assigner":             {"@type": "@id", "@id": "odrl:assigner"},\n\t"assigneeOf":           {"@type": "@id", "@id": "odrl:assigneeOf"},\n    "assignerOf":           {"@type": "@id", "@id": "odrl:assignerOf"},\n    "attributedParty":      {"@type": "@id", "@id": "odrl:attributedParty"},\n\t"attributingParty":     {"@type": "@id", "@id": "odrl:attributingParty"},\n    "compensatedParty":     {"@type": "@id", "@id": "odrl:compensatedParty"},\n    "compensatingParty":    {"@type": "@id", "@id": "odrl:compensatingParty"},\n    "consentingParty":      {"@type": "@id", "@id": "odrl:consentingParty"},\n\t"consentedParty":       {"@type": "@id", "@id": "odrl:consentedParty"},\n    "informedParty":        {"@type": "@id", "@id": "odrl:informedParty"},\n\t"informingParty":       {"@type": "@id", "@id": "odrl:informingParty"},\n    "trackingParty":        {"@type": "@id", "@id": "odrl:trackingParty"},\n\t"trackedParty":         {"@type": "@id", "@id": "odrl:trackedParty"},\n\t"contractingParty":     {"@type": "@id", "@id": "odrl:contractingParty"},\n\t"contractedParty":      {"@type": "@id", "@id": "odrl:contractedParty"},\n\n    "Action":                "odrl:Action",\n    "action":                {"@type": "@vocab", "@id": "odrl:action"},\n    "includedIn":            {"@type": "@id", "@id": "odrl:includedIn"},\n    "implies":               {"@type": "@id", "@id": "odrl:implies"},\n    \n    "Permission":            "odrl:Permission",\n    "permission":            {"@type": "@id", "@id": "odrl:permission"},\n\n    "Prohibition":           "odrl:Prohibition",\n    "prohibition":           {"@type": "@id", "@id": "odrl:prohibition"},\n\n    "obligation":            {"@type": "@id", "@id": "odrl:obligation"},\n\n    "use":                   "odrl:use",\n    "grantUse":              "odrl:grantUse",\n    "aggregate":             "odrl:aggregate",\n    "annotate":              "odrl:annotate",\n    "anonymize":             "odrl:anonymize",\n    "archive":               "odrl:archive",\n    "concurrentUse":         "odrl:concurrentUse",\n    "derive":                "odrl:derive",\n    "digitize":              "odrl:digitize",\n    "display":               "odrl:display",\n    "distribute":            "odrl:distribute",\n    "execute":               "odrl:execute",\n    "extract":               "odrl:extract",\n    "give":                  "odrl:give",\n    "index":                 "odrl:index",\n    "install":               "odrl:install",\n    "modify":                "odrl:modify",\n    "move":                  "odrl:move",\n    "play":                  "odrl:play",\n    "present":               "odrl:present",\n    "print":                 "odrl:print",\n    "read":                  "odrl:read",\n    "reproduce":             "odrl:reproduce",\n    "sell":                  "odrl:sell",\n    "stream":                "odrl:stream",\n    "textToSpeech":          "odrl:textToSpeech",\n    "transfer":              "odrl:transfer",\n    "transform":             "odrl:transform",\n    "translate":             "odrl:translate",\n    \n    "Duty":                 "odrl:Duty",\n    "duty":                 {"@type": "@id", "@id": "odrl:duty"},\n    "consequence":          {"@type": "@id", "@id": "odrl:consequence"},\n\t"remedy":               {"@type": "@id", "@id": "odrl:remedy"},\n\n    "acceptTracking":       "odrl:acceptTracking",\n    "attribute":            "odrl:attribute",\n    "compensate":           "odrl:compensate",\n    "delete":               "odrl:delete",\n    "ensureExclusivity":    "odrl:ensureExclusivity",\n    "include":              "odrl:include",\n    "inform":               "odrl:inform",\n    "nextPolicy":           "odrl:nextPolicy",\n    "obtainConsent":        "odrl:obtainConsent",\n    "reviewPolicy":         "odrl:reviewPolicy",\n    "uninstall":            "odrl:uninstall",\n    "watermark":            "odrl:watermark",\n    \n    "Constraint":           "odrl:Constraint",\n\t"LogicalConstraint":    "odrl:LogicalConstraint",\n    "constraint":           {"@type": "@id", "@id": "odrl:constraint"},\n\t"refinement":           {"@type": "@id", "@id": "odrl:refinement"},\n    "Operator":             "odrl:Operator",\n    "operator":             {"@type": "@vocab", "@id": "odrl:operator"},\n    "RightOperand":         "odrl:RightOperand",\n    "rightOperand":         "odrl:rightOperand",\n    "rightOperandReference":{"@type": "xsd:anyURI", "@id": "odrl:rightOperandReference"},\n    "LeftOperand":          "odrl:LeftOperand",\n    "leftOperand":          {"@type": "@vocab", "@id": "odrl:leftOperand"},\n    "unit":                 "odrl:unit",\n    "dataType":             {"@type": "xsd:anyType", "@id": "odrl:datatype"},\n    "status":               "odrl:status",\n\n    "absolutePosition":        "odrl:absolutePosition",\n    "absoluteSpatialPosition": "odrl:absoluteSpatialPosition",\n    "absoluteTemporalPosition":"odrl:absoluteTemporalPosition",\n    "absoluteSize":            "odrl:absoluteSize",\n    "count":                   "odrl:count",\n    "dateTime":                "odrl:dateTime",\n    "delayPeriod":             "odrl:delayPeriod",\n    "deliveryChannel":         "odrl:deliveryChannel",\n    "elapsedTime":             "odrl:elapsedTime",\n    "event":                   "odrl:event",\n    "fileFormat":              "odrl:fileFormat",\n    "industry":                "odrl:industry:",\n    "language":                "odrl:language",\n    "media":                   "odrl:media",\n    "meteredTime":             "odrl:meteredTime",\n    "payAmount":               "odrl:payAmount",\n    "percentage":              "odrl:percentage",\n    "product":                 "odrl:product",\n    "purpose":                 "odrl:purpose",\n    "recipient":               "odrl:recipient",\n    "relativePosition":        "odrl:relativePosition",\n    "relativeSpatialPosition": "odrl:relativeSpatialPosition",\n    "relativeTemporalPosition":"odrl:relativeTemporalPosition",\n    "relativeSize":            "odrl:relativeSize",\n    "resolution":              "odrl:resolution",\n    "spatial":                 "odrl:spatial",\n    "spatialCoordinates":      "odrl:spatialCoordinates",\n    "systemDevice":            "odrl:systemDevice",\n    "timeInterval":            "odrl:timeInterval",\n    "unitOfCount":             "odrl:unitOfCount",\n    "version":                 "odrl:version",\n    "virtualLocation":         "odrl:virtualLocation",\n\n    "eq":                   "odrl:eq",\n    "gt":                   "odrl:gt",\n    "gteq":                 "odrl:gteq",\n    "lt":                   "odrl:lt",\n    "lteq":                 "odrl:lteq",\n    "neq":                  "odrl:neg",\n    "isA":                  "odrl:isA",\n    "hasPart":              "odrl:hasPart",\n    "isPartOf":             "odrl:isPartOf",\n    "isAllOf":              "odrl:isAllOf",\n    "isAnyOf":              "odrl:isAnyOf",\n    "isNoneOf":             "odrl:isNoneOf",\n    "or":                   "odrl:or",\n    "xone":                 "odrl:xone",\n    "and":                  "odrl:and",\n    "andSequence":          "odrl:andSequence",\n\n    "policyUsage":                "odrl:policyUsage"\n    \n    }\n}\n'}}
Cause: 'contentType'  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 6595, in load_document
    if (remote_doc['contentType'] == 'text/html' or



During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 1220, in to_rdf
    expanded = self.expand(input_, options)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 872, in expand
    inside_list=False)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 2304, in _expand
    active_ctx, element['@context'], options)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 3050, in _process_context
    resolved = options['contextResolver'].resolve(active_ctx, local_ctx, options.get('base', ''))
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 59, in resolve
    active_ctx, ctx, base, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 115, in _resolve_remote_context
    resolved = self.resolve(active_ctx, context, base, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 59, in resolve
    active_ctx, ctx, base, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 108, in _resolve_remote_context
    context, remote_doc = self._fetch_context(active_ctx, url, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 157, in _fetch_context
    code='loading remote context failed')
pyld.jsonld.JsonLdError: ('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.',)
Type: jsonld.InvalidUrl
Code: loading remote context failed
Details: {'url': 'https://www.w3.org/ns/odrl.jsonld', 'cause': JsonLdError('Could not retrieve a JSON-LD document from the URL.',)}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 1129, in normalize
    dataset = self.to_rdf(input_, opts)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 1224, in to_rdf
    'RDF.', 'jsonld.RdfError', cause=cause)
pyld.jsonld.JsonLdError: ('Could not expand input before serialization to RDF.',)
Type: jsonld.RdfError
Cause: ('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.',)
Type: jsonld.InvalidUrl
Code: loading remote context failed
Details: {'url': 'https://www.w3.org/ns/odrl.jsonld', 'cause': JsonLdError('Could not retrieve a JSON-LD document from the URL.',)}  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 1220, in to_rdf
    expanded = self.expand(input_, options)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 872, in expand
    inside_list=False)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 2304, in _expand
    active_ctx, element['@context'], options)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 3050, in _process_context
    resolved = options['contextResolver'].resolve(active_ctx, local_ctx, options.get('base', ''))
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 59, in resolve
    active_ctx, ctx, base, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 115, in _resolve_remote_context
    resolved = self.resolve(active_ctx, context, base, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 59, in resolve
    active_ctx, ctx, base, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 108, in _resolve_remote_context
    context, remote_doc = self._fetch_context(active_ctx, url, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 157, in _fetch_context
    code='loading remote context failed')


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "cert_issuer/__main__.py", line 21, in <module>
    cert_issuer_main()
  File "cert_issuer/__main__.py", line 17, in cert_issuer_main
    issue_certificates.main(parsed_config)
  File "/usr/lib/python3.6/site-packages/cert_issuer/issue_certificates.py", line 36, in main
    return issue(app_config, certificate_batch_handler, transaction_handler)
  File "/usr/lib/python3.6/site-packages/cert_issuer/issue_certificates.py", line 22, in issue
    tx_id = issuer.issue(app_config.chain)
  File "/usr/lib/python3.6/site-packages/cert_issuer/issuer.py", line 23, in issue
    blockchain_bytes = self.certificate_batch_handler.prepare_batch()
  File "/usr/lib/python3.6/site-packages/cert_issuer/certificate_handlers.py", line 109, in prepare_batch
    self.merkle_tree.populate(self.get_certificate_generator())
  File "/usr/lib/python3.6/site-packages/cert_issuer/merkle_tree_generator.py", line 30, in populate
    for data in node_generator:
  File "/usr/lib/python3.6/site-packages/cert_issuer/certificate_handlers.py", line 119, in get_certificate_generator
    data_to_issue = self.certificate_handler.get_byte_array_to_issue(metadata)
  File "/usr/lib/python3.6/site-packages/cert_issuer/certificate_handlers.py", line 15, in get_byte_array_to_issue
    normalized = normalize_jsonld(certificate_json, detect_unmapped_fields=False)
  File "/usr/lib/python3.6/site-packages/cert_schema/jsonld_helpers.py", line 208, in normalize_jsonld
    normalized = jsonld.normalize(json_ld, options=options)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 273, in normalize
    return JsonLdProcessor().normalize(input_, options)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 1133, in normalize
    'jsonld.NormalizeError', cause=cause)
pyld.jsonld.JsonLdError: ('Could not convert input to RDF dataset before normalization.',)
Type: jsonld.NormalizeError
Cause: ('Could not expand input before serialization to RDF.',)
Type: jsonld.RdfError
Cause: ('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.',)
Type: jsonld.InvalidUrl
Code: loading remote context failed
Details: {'url': 'https://www.w3.org/ns/odrl.jsonld', 'cause': JsonLdError('Could not retrieve a JSON-LD document from the URL.',)}  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 1220, in to_rdf
    expanded = self.expand(input_, options)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 872, in expand
    inside_list=False)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 2304, in _expand
    active_ctx, element['@context'], options)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 3050, in _process_context
    resolved = options['contextResolver'].resolve(active_ctx, local_ctx, options.get('base', ''))
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 59, in resolve
    active_ctx, ctx, base, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 115, in _resolve_remote_context
    resolved = self.resolve(active_ctx, context, base, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 59, in resolve
    active_ctx, ctx, base, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 108, in _resolve_remote_context
    context, remote_doc = self._fetch_context(active_ctx, url, cycles)
  File "/usr/lib/python3.6/site-packages/pyld/context_resolver.py", line 157, in _fetch_context
    code='loading remote context failed')
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 1129, in normalize
    dataset = self.to_rdf(input_, opts)
  File "/usr/lib/python3.6/site-packages/pyld/jsonld.py", line 1224, in to_rdf
    'RDF.', 'jsonld.RdfError', cause=cause)

Hi,

Are you referencing a particular context in your blockerts?

Hi @lemoustachiste I am also facing similar issue related to pyld while running command : “cert-issuer -c /etc/cert-issuer/conf.ini”.
Is there any workaround for this issue , do I need to make change in any file?

just remove the vc/examples context from the cert you are issuing.
I suppose you don’t really need it in your case.

If you do, you’ll need to preload it with a documentLoader (extending preloaded contexts) in similar fashion as to cert-schema/jsonld_helpers.py at master · blockchain-certificates/cert-schema · GitHub

Thanks @lemoustachiste , removing the mentioned line worked.