maxmind / minfraud-api-java

Java API for minFraud Score, Insights, and Factors
https://maxmind.github.io/minfraud-api-java
Apache License 2.0
20 stars 8 forks source link

InvalidRequestException when submitting a request that contains unescaped characters #17

Closed rp-julienguery closed 8 years ago

rp-julienguery commented 8 years ago

We have noticed in our use of your API that when a Transaction object contains information with unescaped characters - like á for example - your service can't decode the JSON and an InvalidRequestException exception is thrown by the API with the message There was a problem decoding the request body as a JSON object.

Should your API escape the characters before sending a request? If not, at least specify in the doc how the strings should be escaped/encoded.

Thanks!

oschwald commented 8 years ago

Thanks, this should work. Do you have a code example that reproduces the issue? I tried this:

        Transaction transaction = new Transaction.Builder(
                new Device.Builder(InetAddress.getByName("1.1.1.1")).build()
        ).account(
                new Account.Builder()
                        .username("á")
                        .build()
        ).build();

        InsightsResponse insights = client.insights(transaction);

        System.out.println(insights);

And it seemed to work fine:

com.maxmind.minfraud.response.InsightsResponse [ {"billing_address":{},"credit_card":{"issuer":{}},"device":{},"email":{},"funds_remaining":9999.94,"id":"248d4824-90be-11e6-8d50-b2532f6a299f","ip_address":{"city":{},"continent":{"code":"OC","geoname_id":6255151,"names":{"de":"Ozeanien","ru":"Океания","pt-BR":"Oceania","ja":"オセアニア","en":"Oceania","fr":"Océanie","zh-CN":"大洋洲","es":"Oceanía"}},"country":{"confidence":80,"geoname_id":2077456,"is_high_risk":false,"iso_code":"AU","names":{"de":"Australien","ru":"Австралия","pt-BR":"Austrália","ja":"オーストラリア","en":"Australia","fr":"Australie","zh-CN":"澳大利亚","es":"Australia"}},"location":{"accuracy_radius":1000,"latitude":-25.0,"longitude":135.0},"maxmind":{},"postal":{},"registered_country":{"geoname_id":2077456,"iso_code":"AU","names":{"de":"Australien","ru":"Австралия","pt-BR":"Austrália","ja":"オーストラリア","en":"Australia","fr":"Australie","zh-CN":"澳大利亚","es":"Australia"}},"represented_country":{"geoname_id":6252001,"iso_code":"US","names":{"de":"USA","ru":"США","pt-BR":"Estados Unidos","ja":"アメリカ合衆国","en":"United States","fr":"États-Unis","zh-CN":"美国","es":"Estados Unidos"},"type":"military"},"risk":0.01,"traits":{"ip_address":"1.1.1.1","is_anonymous_proxy":false,"is_legitimate_proxy":false,"is_satellite_provider":false,"isp":"APNIC","organization":"APNIC","user_type":"residential"}},"queries_remaining":666662,"risk_score":1.0,"shipping_address":{}} ]
rp-julienguery commented 8 years ago

If you include more information, like:

        Shipping.Builder shippingBuilder = new Shipping.Builder();
        shippingBuilder.firstName("Allan dias á s maia");
        builder.shipping(shippingBuilder.build());

Then it should fail.

oschwald commented 8 years ago

I am able to reproduce it. We'll take a look at getting a fix out soon.

rp-julienguery commented 8 years ago

Thank you! Keep me posted.

oschwald commented 8 years ago

1.1.1 has been released with a fix for this. It might take a couple of hours for it to show up on mirrors.

rp-julienguery commented 8 years ago

Thank you for the quick fix, appreciate it!