Skip to content

Support resource names containing dots in the api

We stumbled upon a weird behavior with the user profile url for some users like:

https://api.eclipse.org/account/profile/genie.cdt-cloud

This does not return anything and gives no error, while

https://api.eclipse.org/account/profile/genie.cdt-cloud.json does return a correct result.

For other users the url without .json works as well but not for users that already contain a dot in their name like genie.cdt-cloud

My guess is that there is some logic to find the last dot in the path and do some handling with it so https://api.eclipse.org/account/profile/genie.cdt-cloud would translate to a username of genie and extension of .cdt-cloud while https://api.eclipse.org/account/profile/genie.cdt-cloud.json would translate to a user of genie.cdt-cloud and an extension of .json

The problem could be in the services module of drupal that wrongly determines the formatter from the resource path:

https://git.drupalcode.org/project/services/-/blob/7.x-3.x/servers/rest_server/includes/ServicesContentTypeNegotiator.inc#L52

It will always assume that the last dot denotes the format to use for the result.

Maybe a solution would be to alter the resource path when it does not end with .json to always add .json to it to make the behavior consistent with all user names.

There seems to be a hook for the services module that can be used for that:

hook_services_request_preprocess_alter in https://git.drupalcode.org/project/services/-/blob/7.x-3.x/docs/services.alter.api.php

The same problem exists also for projects, e.g.

https://projects.eclipse.org/api/projects/technology_packaging

while

https://projects.eclipse.org/api/projects/technology.packaging.json

works.

Fixing that might resolve some inconsistencies and weird behavior using the api with the existing names of users and projects.