问题
I'm trying to create a managed dynamic link using the Firebase API and the google-api-client Ruby gem. Here's the code I'm using, complete with an inline Gemfile for easier testing:
require 'bundler/inline'
gemfile(true) do
gem 'google-api-client', '~> 0.20'
end
require 'google/apis/firebasedynamiclinks_v1'
require 'cgi'
include Google::Apis::FirebasedynamiclinksV1
service = FirebaseDynamicLinksService.new.tap do |service|
service.authorization = Google::Auth::DefaultCredentials.make_creds(
json_key_io: File.open('path/to/auth.json'),
scope: ['https://www.googleapis.com/auth/firebase']
)
# do this until https://github.com/google/google-api-ruby-client/issues/652
# is fixed
service.instance_variable_set(
:@root_url, 'https://firebasedynamiclinks.googleapis.com/'
)
end
link = CGI.escape('http://example.com')
request = CreateManagedShortLinkRequest.new(
long_dynamic_link: "https://f4w25.app.goo.gl/?link=#{link}&ibi=com.foo.bar",
name: 'Test test'
)
service.create_managed_short_link(request)
This script errors with Server error (Google::Apis::ServerError)
. The body of the response is:
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"errors": [
{
"message": "Internal error encountered.",
"domain": "global",
"reason": "backendError"
}
],
"status": "INTERNAL"
}
}
回答1:
Please use CreateShortDynamicLinkRequest
instead of CreateManagedShortLinkRequest
.
来源:https://stackoverflow.com/questions/50261812/why-am-i-getting-a-server-error-from-the-firebase-dynamic-links-api