等效的rest API调用:";heroku pg:credentials数据库“URL——应用程序mypgapp”;
返回包含RELEVENT PG加载项信息的JSON,但不提供CLI随命令提供的连接字符串。我想通过Heroku REST API获得的是主机、端口、数据库名、用户和密码等效的rest API调用:";heroku pg:credentials数据库“URL——应用程序mypgapp”;,heroku,heroku-toolbelt,heroku-postgres,heroku-api,Heroku,Heroku Toolbelt,Heroku Postgres,Heroku Api,返回包含RELEVENT PG加载项信息的JSON,但不提供CLI随命令提供的连接字符串。我想通过Heroku REST API获得的是主机、端口、数据库名、用户和密码 这可能吗?我发现查看Heroku CLI的调试输出非常有用。在这种情况下,可以从环境变量中获取查询字符串: curl -n -X GET https://api.heroku.com/apps/mypgapp/addons/heroku-postgresql -H "Content-Type: application/json"
这可能吗?我发现查看Heroku CLI的调试输出非常有用。在这种情况下,可以从环境变量中获取查询字符串:
curl -n -X GET https://api.heroku.com/apps/mypgapp/addons/heroku-postgresql
-H "Content-Type: application/json"
-H "Accept: application/vnd.heroku+json; version=3"
这不是heroku pg:credentials使用的API。它实际上使用了Heroku自己的v2 API
DEBUG=1 HEROKU_DEBUG=1 heroku config:get -a mypgapp DATABASE_URL ❖ ruby-2.3.0
heroku-cli/5.2.12-09f3ecc (darwin-amd64) go1.6.2 /Users/bjeanes/.local/share/heroku/cli/bin/heroku cmd: version
heroku-cli/5.2.12-09f3ecc (darwin-amd64) go1.6.2 /Users/bjeanes/.local/share/heroku/cli/bin/heroku cmd: commands
heroku-cli/5.2.12-09f3ecc (darwin-amd64) go1.6.2 /Users/bjeanes/.local/share/heroku/cli/bin/heroku cmd: config:get
--> GET /apps/mypgapp/config-vars
<-- 200 OK
<-- {"DATABASE_URL":"postgres://REDACTED@ec2-174-129-223-35.compute-1.amazonaws.com:5432/dfbe4e6vs4diqb"}
postgres://REDACTED@ec2-174-129-223-35.compute-1.amazonaws.com:5432/dfbe4e6vs4diqb
$ curl -n -H 'Accept: application/vnd.heroku+json; version=3' \
https://api.heroku.com/apps/mypgapp/config-vars | jq .DATABASE_URL
postgres://REDACTED@ec2-174-129-223-35.compute-1.amazonaws.com:5432/dfbe4e6vs4diqb