Api Platform conference
Register now
v2.4 Troubleshooting
API Platform Conference
September 19-20, 2024 | Lille & online

The international conference on the API Platform Framework

API Platform Conference 2024: meet the best PHP, JavaScript and API experts

Learn more about the event, register for the conference, and get ready for two days of inspiration, ideas, and knowledge-sharing with our incredible lineup of renowned specialists and advocates.

Register now

Troubleshooting

  • If you are running API Platform on development machine which does not have valid TLS certificate, add NODE_TLS_REJECT_UNAUTHORIZED=0 before running client-generator
NODE_TLS_REJECT_UNAUTHORIZED=0 npx @api-platform/client-generator --generator typescript https://127.0.0.1:8000/api src/
  • The generator does not perform any authentication, so you must ensure that all referenced Hydra paths for your API are accessible anonymously. If you are using API Platform this will at least include:
api_entrypoint                             ANY      ANY      ANY    /{index}.{_format}
api_doc                                    ANY      ANY      ANY    /docs.{_format}
api_jsonld_context                         ANY      ANY      ANY    /contexts/{shortName}.{_format}
  • If you receive Error: The class http://www.w3.org/ns/hydra/core#ApiDocumentation doesn't exist. you may have specified the documentation URL instead of the entrypoint. For example if you are using API Platform and your documentation URL is at https://demo.api-platform.com/docs the entry point is likely at https://demo.api-platform.com. You can see an example of the expected response from an entrypoint in your browser by visiting https://demo.api-platform.com/index.jsonld.

  • If you receive TypeError: Cannot read property '@type' of undefined or TypeError: Cannot read property '0' of undefined check that the URL you specified is accessible and returns jsonld. You can check from the command line you are using by running something like curl https://demo.api-platform.com/.

  • If you receive a message like this:

{ Error
at done (/usr/local/share/.config/yarn/global/node_modules/jsonld/js/jsonld.js:6851:19)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
name: 'jsonld.InvalidUrl',
message: 'Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object.',
details:
{ code: 'invalid remote context',
 url: 'https://demo.api-platform.com/contexts/Entrypoint',
 cause: null } }

Check access to the specified url, in this case https://demo.api-platform.com/contexts/Entrypoint, use curl to check access and the response curl https://demo.api-platform.com/contexts/Entrypoint. In the above case an “Access Denied” message in JSON format was being returned.

You can also help us improve the documentation of this page.

Made with love by

Les-Tilleuls.coop can help you design and develop your APIs and web projects, and train your teams in API Platform, Symfony, Next.js, Kubernetes and a wide range of other technologies.

Learn more

Copyright © 2023 Kévin Dunglas

Sponsored by Les-Tilleuls.coop