When I open page in browser I am getting:
{"id":"786938997027","name":"users","isSystem":false,"status":3,"type":2,"error":false,"code":200}
When I am sending request from code, I am getting next output:
Response: {"error":true,"code":400,"errorNum":1208,"errorMessage":"name must be non-empty"}
What's wrong?
void foo()
{
string url = "http://localhost:8529/_db/testdb/_api/collection/users";
import std.experimental.logger;
globalLogLevel(LogLevel.info);
Json users;
requestHTTP(url,
(scope req) {
req.method = HTTPMethod.POST;
},
(scope res) {
logInfo("Response: %s", res.bodyReader.readAllUTF8());
users = res.bodyReader.readAllUTF8();
}
);
}
You need to use GET type of request as @Colonel Thirty Two mentioned. So remove this line:
req.method = HTTPMethod.POST;
or change it to:
req.method = HTTPMethod.GET;