mailjet / mailjet-apiv3-java

[API v3] Mailjet Java API Wrapper
https://dev.mailjet.com
MIT License
66 stars 36 forks source link

Cannot use Sort #155

Closed kbilev closed 3 years ago

kbilev commented 3 years ago

Hello, using the filter to Sort descending does not work and gives an error message.

request = new MailjetRequest(Message.resource).filter("Sort", "id+DESC"); response = client.get(request);

Error Message: com.mailjet.client.errors.MailjetClientRequestException: { "ErrorInfo" : "", "ErrorMessage" : "Unexpected error during GET: Invalid sort specification: Cannot sort on field id+desc", "StatusCode" : 400 }

It seems that an similar problem existed in the Python API: https://github.com/mailjet/mailjet-apiv3-python/issues/46

sdiakovskyi-gd commented 3 years ago

Hello @kev912002 ,

Thanks for raising this issue! The root cause is with encoding the plus sign. I can fix it directly in the client, but this could break some other cases, and I believe, it's a bit against HTML URL Encoding standards.

More preferable solution is just use space symbol as separator:

        MailjetRequest mailjetRequestDesc = new MailjetRequest(Message.resource)
                .filter("Sort", "id DESC");

I'll add tests and update the docs.

jeremylynch commented 1 year ago

The API docs should be updated, they are misleading with the +DESC