2

Pretty much what it says on the tin... I'm using MongoHQ's REST API to create a database, but for some reason the default user account that gets created when adding a database manually via the web page does not get created when the API is used. Am I missing some API documentation that indicates this is the expected behavior? Is it a bug? In any case, how can I programmatically add user accounts to a database? Or is it possible?

For reference, MongoHQ's documentation is here: http://support.mongohq.com/mongohq-api/databases.html

cbmanica
  • 3,502
  • 7
  • 36
  • 54

2 Answers2

0

MongoHQ support has informed me that this is a bug in their API and there is no workaround. A fix is in the works, but there is no timetable for its release.

cbmanica
  • 3,502
  • 7
  • 36
  • 54
0

After Googling around, I found this PHP MongoHQ API library. They had a create user function in there. I took a look, broke it apart, tested it and it works! It's undocumented, but it does allow you to add users to a database.

POST to:

https://api.mongohq.com/databases/*YOUR-DATABASE*/collections/system.users/documents?_apikey=XXXXXXXXXXXXXXXX

With a JSON payload:

{"document":{"user":"danmandle", "pwd":"test", "readonly":false}}
Dan Mandle
  • 5,608
  • 3
  • 23
  • 26
  • Interesting! I'm not in a position to try this anymore, but if someone else comments and says it works for them I'll accept this answer. Thanks! – cbmanica Jun 11 '14 at 01:06