You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
begin
nylas = Nylas::API.new(
app_id: "CLIENT_ID",
app_secret: "CLIENT_SECRET",
access_token: "ACCESS_TOKEN"
)
nylas.exchange_code_for_token("abc")
rescue => e
p e
p e.message # This should contain valid info and not just 'message'
end
Output:
#<Nylas::InvalidRequest: message>
"message"
We set a content-header type by default, but not an accept header. We should add it in to prevent some error messages not being formatted as JSON. Closes#405.
Describe the bug
Nylas API seems to return a html response for error cases unless 'Accept: application/json' is explicitly specified https://developer.nylas.com/docs/api/#post/oauth/token
This leads to invalid exception messages as this gem is expecting a json response back.
I do not see 'Accept: application/json' in default_headers in https://github.com/nylas/nylas-ruby/blob/main/lib/nylas/http_client.rb#L180-L186 Either setting this within gem or returning a default application/json in case content-type: application/json from nylas api should fix this.
To Reproduce
Ruby Code
Curl with Accept: application/json
Curl without Accept: application/json
Expected behavior
Exceptions should contain correct information and messages so calling clients can appropriately classify / take decisions
nylas-ruby/lib/nylas/errors.rb
Lines 49 to 55 in ef90d46
SDK Version:
nylas (5.14.0)
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: