When a node is created via JSON API module, the pathauto does not generate the URL alias, but instead it is /node/[nid].

When a node is created manually thru the GUI, the pathauto works correctly.

This problem started occurring when I updated recently. I am on D8.4.4

Comments

Houmanvg created an issue. See original summary.

Houmanvg’s picture

Issue summary: View changes
e0ipso’s picture

This seems a problem in Pathauto and not in JSON API. Did you report it in that issue queue?

wim leers’s picture

Project: JSON:API » Pathauto
Version: 8.x-1.7 » 8.x-1.x-dev

Moving to the pathauto issue queue.

Houmanvg’s picture

Issue occurs for both REST as well as JSON API module.

berdir’s picture

Status: Needs work » Postponed (maintainer needs more info)

There were various reports since 8.4 about strange effects. Only found time now to start looking into it. Can you check if #2945734: Fix automated test failures in 8.x-1.x is fixing this for you?

If not, a failing test would be helpful.

Antviolence’s picture

I had the same problem (using an old version of JSON API). I don't know if this is any help at all to solve a potential problem, but maybe it can at least help someone until the problem has been found and fixed (if there indeed is a real problem).

Using Pathauto dev-1.x 59a7bef with the https://www.drupal.org/files/issues/pathauto-84-updates-2945734-4.patch (after first trying it on 8.x-1.0).

When creating a node through JSON API POST, pathauto stopped working when upgrading from Drupal 8.2 to 8.4 (generally speaking, though it sometimes seems to be able to create the path other than /node/[nid], but mostly not). The only solution to the problem I've found so far is to change the body of the post to contain the pathauto pattern ([current-date:url_date]/[node:nid]/[node:title]) for the entity type.

Worked in 8.2: "path":{"alias":"","pid":null,"langcode":en"}

Working in 8.4: "path"{"alias":"[current-date:html_date]\/[node:nid]}/[node:title]","pid":null,"langcode":en"}

I have not tried this on 8.x-1.0 yet, but I guess it might work there as well.

Edit:

It actually sometimes does create the alias, but mostly not. I have not been able to see any pattern to this.

And come to think of it, I can't confirm what was sent in Drupal 8.2, since I no longer have any such installation remaining, so I can't be sure if path was sent at all, or what it contained.

cgmonroe’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

This has the same symptoms / solution as #2946273: Alias is not generated when Pathauto widget is hidden,

Basically new nodes will not get the alias generated if something touches the path field before the entity is saved. Patch in the issue above will probably fix this. If not, change the status back.