cloudant / java-cloudant

A Java client for Cloudant
Apache License 2.0
79 stars 68 forks source link

[err] com.cloudant.client.org.lightcouch.CouchDbException: 400 Bad Request: bad_request: Referer header required. #313

Closed sandrodesantis closed 8 years ago

sandrodesantis commented 8 years ago

Please include the following information in your ticket.

And I'm receiving ERROR message, looks like PUT commands don't working.

These commands are working very well:

// Note: for Cloudant Local or Apache CouchDB use: CloudantClient client = ClientBuilder.url(new URL("http://0.0.0.0:5984")).username("admin") .password("xxxx").disableSSLAuthentication().build();

// Show the server version System.out.println("Server Version: " + client.serverVersion());

// Show databases System.out.println("Dbs: " + client.getAllDbs());

// Get database Database db1 = client.database("dash-db", true);

These commands are NOT working :

=> not working! db1.createIndex("type", "type", null, new IndexField[]{ new IndexField("type",SortOrder.asc)});

=> not working List objTOList = db.findByIndex("\"selector\": {\"type\": \"adoption\"}", ObjTO.class); System.out.println("objTOList " + objTOList);

Exception =>

[err] com.cloudant.client.org.lightcouch.CouchDbException: 400 Bad Request: bad_request: Referer header required. [err] at com.cloudant.client.org.lightcouch.CouchDbClient.execute(CouchDbClient.java:524) [err] at com.cloudant.client.org.lightcouch.CouchDbClient.executeToInputStream(CouchDbClient.java:572) [err] at com.cloudant.client.api.Database.createIndex(Database.java:305) [err] at com.cloudant.client.api.Database.createIndex(Database.java:288)

Any idea ?, thanks !

Sandro

ricellis commented 8 years ago

@sandrodesantis what version of Cloudant Local are you using?

ricellis commented 8 years ago

The createIndex and findByIndex methods utilize the Cloudant query endpoints _index and _find. Those endpoints are not available in CouchDB 1.6 and it returns the 400 Bad Request Referer header required error. The requests will work if you use Cloudant Local or the Cloudant service.