Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorReport class shape does not match API response #91

Closed
akosasante opened this issue Jan 16, 2020 · 2 comments
Closed

ErrorReport class shape does not match API response #91

akosasante opened this issue Jan 16, 2020 · 2 comments

Comments

@akosasante
Copy link

akosasante commented Jan 16, 2020

We are using the MessageBirdClient.sendVoiceCall method to initiate phone calls. We were able to catch exceptions when the voice call request fails. However, we also expected to be able to use the MessageBirdException.getErrors method to pull out the particular error code returned (not just the HTTP status code). Instead, the method returns null.

As per the code here and the status codes outlined in the API docs here: (eg. 25 for "not enough balance").

It looks to me like the issue is here in MessageBirdServiceImpl where the body of the failed HTTP request is mapped onto the ErrorReport[] class. The fields of an error I received when testing the API via cURL ("message", "code") do not match the fields of the ErrorReport class ("description", "code", "parameter"):

{
  "errors": [
    {
      "message": "You're not authorized to access this resource.",
      "code": 14
    }
  ]
}

vs

public class ErrorReport {
    private Integer code;
    private String description;
    private String parameter;
...

I am not sure if those fields ErrorReport class are expected elsewhere or with different types of errors. The only one we were able to manually test is when we receive a 403 "unauthorized" for using the incorrect API key.

(CC: @katchengli)

@denizkilic
Copy link
Contributor

Hello @akosasante,
Thanks for reporting this issue. I did a quick test. The problem caused because our APIs return back an error with different fields. For example, rest API returns code, description, parameter fields in error object but voice API returns message and code parameters. That's why it cannot parse to ErrorReport object. We will fix this problem.

@denizkilic
Copy link
Contributor

Hi @akosasante,
Regarding this issue, we have just released version 3.0.8. We added the 'message' field which is not null in voice api results. Thank you and we are welcoming more issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants