I did two standard installs, one with postgres and one with mysql. For both I only enabled Entity API and RestWS. I created a test article as node/1. Visiting node/1.json on the mysql install works as expected. Using the postgres install, it fails giving the error:
PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "1.json" LINE 5: WHERE (base.nid IN ('1.json')) ^: SELECT revision.vid AS vid, base.uid AS uid, revision.title AS title, revision.log AS log, revision.status AS status, revision.comment AS comment, revision.promote AS promote, revision.sticky AS sticky, base.nid AS nid, base.type AS type, base.language AS language, base.created AS created, base.changed AS changed, base.tnid AS tnid, base.translate AS translate, revision.timestamp AS revision_timestamp, revision.uid AS revision_uid FROM {node} base INNER JOIN {node_revision} revision ON revision.vid = base.vid WHERE (base.nid IN (:db_condition_placeholder_0)) ; Array ( [:db_condition_placeholder_0] => 1.json ) in DrupalDefaultEntityController->load() (line 196 of /Users/rkoberg/Sites/wgb/www/includes/entity.inc).

Next, I tried the Firefox extension RESTClient in the same browser and set the Accept header to application/json and used node/1 (no .json extension) and it worked as expected. Next, I changed the admin/people/permissions for "RESTful web services > Access the resource node" to allow anonymous and authenticated and tried with curl:
$ curl -i -H "Accept: application/json" http://local/wgb/www/node/1
And it worked as expected. Just in case I tried accessing node/1.json from the same firefox as the RESTClient (logged in as user/1) and receive the same error as above.

Any ideas?

Comments

klausi’s picture

Status: Active » Closed (duplicate)

I think this is a duplicate of #1003788: PostgreSQL: PDOException:Invalid text representation when attempting to load an entity with a string or non-scalar ID.

Using the format extension like ".json" or ".xml" is not recommended anyway - use the accept headers when possible.