question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong url for item operations

See original GitHub issue

Hello, The url used to get/put/delete a ressource in api-platform/admin is a wrong one : the main path is mentioned twice (see pictures below). image image

I only have this porblem for item operations. Collection operations work fine.

I am not sure if the problem comes from the writing of docs.jsonld in api-platform/api-platform or its reading in api-platform/admin.

Below is my docs.jsonld. It has been made with api-platform/demo using composer for installation. Thanks for your help,

{
  "@context": {
    "@vocab": "http://localhost/demo/web/app_dev.php/docs.jsonld#",
    "hydra": "http://www.w3.org/ns/hydra/core#",
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "xmls": "http://www.w3.org/2001/XMLSchema#",
    "owl": "http://www.w3.org/2002/07/owl#",
    "domain": {
      "@id": "rdfs:domain",
      "@type": "@id"
    },
    "range": {
      "@id": "rdfs:range",
      "@type": "@id"
    },
    "subClassOf": {
      "@id": "rdfs:subClassOf",
      "@type": "@id"
    },
    "expects": {
      "@id": "hydra:expects",
      "@type": "@id"
    },
    "returns": {
      "@id": "hydra:returns",
      "@type": "@id"
    }
  },
  "@id": "../demo/web/app_dev.php/docs.jsonld",
  "hydra:description": "This is a demo application of the [API Platform](https://api-platform.com) framework.\n[Its source code](https://github.com/api-platform/demo) includes various examples, check it out!\n",
  "hydra:entrypoint": "/demo/web/app_dev.php/",
  "hydra:supportedClass": [
    {
      "@id": "http://schema.org/Book",
      "@type": "hydra:Class",
      "rdfs:label": "Book",
      "hydra:supportedOperation": [
        {
          "@type": "hydra:Operation",
          "rdfs:label": "Retrieves Book resource.",
          "hydra:method": "GET",
          "returns": "http://schema.org/Book",
          "hydra:title": "Retrieves Book resource."
        },
        {
          "@type": "hydra:ReplaceResourceOperation",
          "rdfs:label": "Replaces the Book resource.",
          "expects": "http://schema.org/Book",
          "hydra:method": "PUT",
          "returns": "http://schema.org/Book",
          "hydra:title": "Replaces the Book resource."
        },
        {
          "@type": "hydra:Operation",
          "rdfs:label": "Deletes the Book resource.",
          "hydra:method": "DELETE",
          "returns": "owl:Nothing",
          "hydra:title": "Deletes the Book resource."
        }
      ],
      "hydra:supportedProperty": [
        {
          "@type": "hydra:SupportedProperty",
          "hydra:property": {
            "@id": "#Book/id",
            "@type": "rdf:Property",
            "domain": "http://schema.org/Book",
            "rdfs:label": "id",
            "range": "xmls:integer"
          },
          "hydra:readable": true,
          "hydra:required": false,
          "hydra:title": "id",
          "hydra:writable": true
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:description": "The ISBN of the book",
          "hydra:property": {
            "@id": "http://schema.org/isbn",
            "@type": "rdf:Property",
            "domain": "http://schema.org/Book",
            "rdfs:label": "isbn",
            "range": "xmls:string"
          },
          "hydra:readable": true,
          "hydra:required": false,
          "hydra:title": "isbn",
          "hydra:writable": true
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:description": "A description of the item",
          "hydra:property": {
            "@id": "http://schema.org/description",
            "@type": "rdf:Property",
            "domain": "http://schema.org/Book",
            "rdfs:label": "description",
            "range": "xmls:string"
          },
          "hydra:readable": true,
          "hydra:required": true,
          "hydra:title": "description",
          "hydra:writable": true
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:description": "The author of this content or rating. Please note that author is special in that HTML 5 provides a special mechanism for indicating authorship via the rel tag. That is equivalent to this and may be used interchangeably",
          "hydra:property": {
            "@id": "http://schema.org/author",
            "@type": "rdf:Property",
            "domain": "http://schema.org/Book",
            "rdfs:label": "author",
            "range": "xmls:string"
          },
          "hydra:readable": true,
          "hydra:required": true,
          "hydra:title": "author",
          "hydra:writable": true
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:description": "The title of the book",
          "hydra:property": {
            "@id": "http://schema.org/name",
            "@type": "rdf:Property",
            "domain": "http://schema.org/Book",
            "rdfs:label": "title",
            "range": "xmls:string"
          },
          "hydra:readable": true,
          "hydra:required": true,
          "hydra:title": "title",
          "hydra:writable": true
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:description": "The date on which the CreativeWork was created or the item was added to a DataFeed",
          "hydra:property": {
            "@id": "http://schema.org/dateCreated",
            "@type": "rdf:Property",
            "domain": "http://schema.org/Book",
            "rdfs:label": "publicationDate",
            "range": "xmls:dateTime"
          },
          "hydra:readable": true,
          "hydra:required": true,
          "hydra:title": "publicationDate",
          "hydra:writable": true
        }
      ],
      "hydra:title": "Book"
    },
    {
      "@id": "http://schema.org/Review",
      "@type": "hydra:Class",
      "rdfs:label": "Review",
      "hydra:supportedOperation": [
        {
          "@type": "hydra:Operation",
          "rdfs:label": "Retrieves Review resource.",
          "hydra:method": "GET",
          "returns": "http://schema.org/Review",
          "hydra:title": "Retrieves Review resource."
        },
        {
          "@type": "hydra:ReplaceResourceOperation",
          "rdfs:label": "Replaces the Review resource.",
          "expects": "http://schema.org/Review",
          "hydra:method": "PUT",
          "returns": "http://schema.org/Review",
          "hydra:title": "Replaces the Review resource."
        },
        {
          "@type": "hydra:Operation",
          "rdfs:label": "Deletes the Review resource.",
          "hydra:method": "DELETE",
          "returns": "owl:Nothing",
          "hydra:title": "Deletes the Review resource."
        }
      ],
      "hydra:supportedProperty": [
        {
          "@type": "hydra:SupportedProperty",
          "hydra:property": {
            "@id": "#Review/id",
            "@type": "rdf:Property",
            "domain": "http://schema.org/Review",
            "rdfs:label": "id",
            "range": "xmls:integer"
          },
          "hydra:readable": true,
          "hydra:required": false,
          "hydra:title": "id",
          "hydra:writable": true
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:property": {
            "@id": "#Review/rating",
            "@type": "rdf:Property",
            "domain": "http://schema.org/Review",
            "rdfs:label": "rating",
            "range": "xmls:integer"
          },
          "hydra:readable": true,
          "hydra:required": false,
          "hydra:title": "rating",
          "hydra:writable": true
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:description": "The actual body of the review",
          "hydra:property": {
            "@id": "http://schema.org/reviewBody",
            "@type": "rdf:Property",
            "domain": "http://schema.org/Review",
            "rdfs:label": "body",
            "range": "xmls:string"
          },
          "hydra:readable": true,
          "hydra:required": false,
          "hydra:title": "body",
          "hydra:writable": true
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:description": "The item that is being reviewed/rated",
          "hydra:property": {
            "@id": "http://schema.org/itemReviewed",
            "@type": "hydra:Link",
            "domain": "http://schema.org/Review",
            "rdfs:label": "book",
            "range": "http://schema.org/Book"
          },
          "hydra:readable": true,
          "hydra:required": true,
          "hydra:title": "book",
          "hydra:writable": true
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:description": "Author the author of the review",
          "hydra:property": {
            "@id": "http://schema.org/author",
            "@type": "rdf:Property",
            "domain": "http://schema.org/Review",
            "rdfs:label": "author",
            "range": "xmls:string"
          },
          "hydra:readable": true,
          "hydra:required": false,
          "hydra:title": "author",
          "hydra:writable": true
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:description": "Author the author of the review",
          "hydra:property": {
            "@id": "#Review/publicationDate",
            "@type": "rdf:Property",
            "domain": "http://schema.org/Review",
            "rdfs:label": "publicationDate",
            "range": "xmls:dateTime"
          },
          "hydra:readable": true,
          "hydra:required": false,
          "hydra:title": "publicationDate",
          "hydra:writable": true
        }
      ],
      "hydra:title": "Review"
    },
    {
      "@id": "#Entrypoint",
      "@type": "hydra:Class",
      "hydra:supportedOperation": {
        "@type": "hydra:Operation",
        "rdfs:label": "The API entrypoint.",
        "hydra:method": "GET",
        "returns": "#EntryPoint"
      },
      "hydra:supportedProperty": [
        {
          "@type": "hydra:SupportedProperty",
          "hydra:property": {
            "@id": "#Entrypoint/book",
            "@type": "hydra:Link",
            "domain": "#Entrypoint",
            "rdfs:label": "The collection of Book resources",
            "range": "hydra:PagedCollection",
            "hydra:supportedOperation": [
              {
                "@type": "hydra:Operation",
                "rdfs:label": "Retrieves the collection of Book resources.",
                "hydra:method": "GET",
                "returns": "hydra:PagedCollection",
                "hydra:title": "Retrieves the collection of Book resources."
              },
              {
                "@type": "hydra:CreateResourceOperation",
                "rdfs:label": "Creates a Book resource.",
                "expects": "http://schema.org/Book",
                "hydra:method": "POST",
                "returns": "http://schema.org/Book",
                "hydra:title": "Creates a Book resource."
              }
            ]
          },
          "hydra:readable": true,
          "hydra:title": "The collection of Book resources",
          "hydra:writable": false
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:property": {
            "@id": "#Entrypoint/review",
            "@type": "hydra:Link",
            "domain": "#Entrypoint",
            "rdfs:label": "The collection of Review resources",
            "range": "hydra:PagedCollection",
            "hydra:supportedOperation": [
              {
                "@type": "hydra:Operation",
                "rdfs:label": "Retrieves the collection of Review resources.",
                "hydra:method": "GET",
                "returns": "hydra:PagedCollection",
                "hydra:title": "Retrieves the collection of Review resources."
              },
              {
                "@type": "hydra:CreateResourceOperation",
                "rdfs:label": "Creates a Review resource.",
                "expects": "http://schema.org/Review",
                "hydra:method": "POST",
                "returns": "http://schema.org/Review",
                "hydra:title": "Creates a Review resource."
              }
            ]
          },
          "hydra:readable": true,
          "hydra:title": "The collection of Review resources",
          "hydra:writable": false
        }
      ],
      "hydra:title": "The API entrypoint"
    },
    {
      "@id": "#ConstraintViolation",
      "@type": "hydra:Class",
      "hydra:supportedProperty": [
        {
          "@type": "hydra:SupportedProperty",
          "hydra:description": "The property path of the violation",
          "hydra:property": {
            "@id": "#ConstraintViolation/propertyPath",
            "@type": "rdf:Property",
            "domain": "#ConstraintViolation",
            "rdfs:label": "propertyPath",
            "range": "xmls:string"
          },
          "hydra:readable": true,
          "hydra:title": "propertyPath",
          "hydra:writable": false
        },
        {
          "@type": "hydra:SupportedProperty",
          "hydra:description": "The message associated with the violation",
          "hydra:property": {
            "@id": "#ConstraintViolation/message",
            "@type": "rdf:Property",
            "domain": "#ConstraintViolation",
            "rdfs:label": "message",
            "range": "xmls:string"
          },
          "hydra:readable": true,
          "hydra:title": "message",
          "hydra:writable": false
        }
      ],
      "hydra:title": "A constraint violation"
    },
    {
      "@id": "#ConstraintViolationList",
      "@type": "hydra:Class",
      "subClassOf": "hydra:Error",
      "hydra:supportedProperty": {
        "@type": "hydra:SupportedProperty",
        "hydra:description": "The violations",
        "hydra:property": {
          "@id": "#ConstraintViolationList/violations",
          "@type": "rdf:Property",
          "domain": "#ConstraintViolationList",
          "rdfs:label": "violations",
          "range": "#ConstraintViolation"
        },
        "hydra:readable": true,
        "hydra:title": "violations",
        "hydra:writable": false
      },
      "hydra:title": "A constraint violation list"
    }
  ],
  "hydra:title": "API Platform's demo"
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
sushicodeurcommented, Sep 5, 2017

I got it working, but it’s an ugly fix :

  • copied nodes_module/api-platform-admin/dist in src/local-api-platform-admin

  • modified src/local-api-platform-admin/hydra/hydraClient.js like so :

    • added an import : import Url from 'dom-urls';
    • edited convertAORRequestToHydraRequest :
var convertAORRequestToHydraRequest = function convertAORRequestToHydraRequest(type, resource, params) {
    var _fetchUtils$queryPara;
    var entrypointUrl = new Url(entrypoint);

    switch (type) {
      case CREATE:
        return convertAORDataToHydraData(resource, params.data).then(function (data) {
          return {
            options: {
              body: _JSON$stringify(data),
              method: 'POST'
            },
            url: entrypoint + '/' + resource
          };
        });

      case DELETE:
        return _Promise.resolve({
          options: {
            method: 'DELETE'
          },
          url: entrypointUrl.origin + params.id
        });

      case GET_LIST:
        {
          var page = params.pagination.page;


          return _Promise.resolve({
            options: {},
            url: entrypoint + '/' + resource + '?' + fetchUtils.queryParameters(_extends({}, params.filter, {
              page: page
            }))
          });
        }

      case GET_MANY_REFERENCE:
        return _Promise.resolve({
          options: {},
          url: entrypoint + '/' + resource + '?' + fetchUtils.queryParameters((_fetchUtils$queryPara = {}, _fetchUtils$queryPara[params.target] = params.id, _fetchUtils$queryPara))
        });

      case GET_ONE:
        return _Promise.resolve({
          options: {},
          url: entrypointUrl.origin + params.id
        });

      case UPDATE:
        return convertAORDataToHydraData(resource, params.data).then(function (data) {
          return {
            options: {
              body: _JSON$stringify(data),
              method: 'PUT'
            },
            url: entrypointUrl.origin + params.id
          };
        });

      default:
        throw new Error('Unsupported fetch action type ' + type);
    }
  };
  • and in App.js changed the import : import HydraAdmin from './local-api-platform-admin/hydra/HydraAdmin';

I’m really not sure the implications of my fix, so (1) use it at your own risk and not in production (2) I’ll not propose any PR for that 😉 But if it can help people like me to get an idea of the pros and cons of using this software, it’ll probably get you running.

1reaction
toulemolcommented, Aug 25, 2017

@npeham thanks for the answer. I also had to make sure there was no prefix in the path.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong URL generated for link to Custom item - WordPress.org
First thing to do would be to empty Optimole cache – will do that. Otherwise, any time I see tags like “data” I...
Read more >
"The URL is invalid" error message when you upload a file to ...
When you upload a file to a SharePoint Online or SharePoint 2013 list, you receive the following error message: The URL <file name>...
Read more >
Troubleshooting Cloudflare 10XXX errors
This error occurs when there are different types of list items (both IP addresses and URL redirects) in a single operation to add...
Read more >
URL Loading System Error Codes - Apple Developer
Error codes returned by URL loading APIs. ... A specific request to load an item only from the cache couldn't be ... An...
Read more >
5 common mistakes with rel=canonical - Google Developers
Make sure you'd prefer the rel=canonical URL to be displayed in search results (rather than the duplicate URL). Include the rel=canonical link in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found