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

Pinpoint SDK sends 3 character country code, causing API error #354

Closed
gmenel opened this issue Oct 17, 2017 · 12 comments
Closed

Pinpoint SDK sends 3 character country code, causing API error #354

gmenel opened this issue Oct 17, 2017 · 12 comments
Assignees
Labels
pinpoint Issues with the AWS Android SDK for Pinpoint.

Comments

@gmenel
Copy link

gmenel commented Oct 17, 2017

No description provided.

@mutablealligator mutablealligator added the pinpoint Issues with the AWS Android SDK for Pinpoint. label Oct 17, 2017
@mutablealligator
Copy link
Contributor

We released 2.6.6 that fixes the issue.

@jonasfunk
Copy link

With the country value of CAN, Using 2.6.6 I'm getting this,

com.amazonaws.services.pinpoint.model.BadRequestException: Country should be 2 character ISO 3166-1 Alpha-2 codes or UN M.49 numeric-3 area code (Service: AmazonPinpoint; Status Code: 400; Error Code: BadRequestException; Request ID: 2f9bd4bf-be42-11e7-b5bf-c75bf67bda00)
TargetingClient: at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:729)
TargetingClient: at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:405)
TargetingClient: at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:212)
TargetingClient: at com.amazonaws.services.pinpoint.AmazonPinpointClient.invoke(AmazonPinpointClient.java:3303)
TargetingClient: at com.amazonaws.services.pinpoint.AmazonPinpointClient.updateEndpoint(AmazonPinpointClient.java:3053)
TargetingClient: at com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient$1.run(TargetingClient.java:194)
TargetingClient: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
TargetingClient: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
TargetingClient: at java.lang.Thread.run(Thread.java:762)

@Arpanbajpai
Copy link

@kvasukib Please help me out to implement AWS Pinpoint notification in android. i am getting the same issue ( com.amazonaws.services.pinpoint.model.BadRequestException: Country should be 2 character ISO 3166-1 Alpha-2 or Alpha-3 codes or UN M.49 numeric-3 area code ) as above as in TargetingClient class the EndpointLocation is unable to get city,country etc. I have researched and found that
context.getApplicationContext().getResources().getConfiguration().locale.getISO3Country() has been deprecated since sdk 24 and new version to get the list is
LocaleListCompat list = ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration());

Please help to implement it ASAP.

@mutablealligator
Copy link
Contributor

mutablealligator commented Feb 6, 2019

@Arpanbajpai Sorry for the inconvenience caused.
What Android API Level are you running against?
Do you see the log message "Locale getISO3Country failed, falling back to getCountry." in your Logcat?
Can you put a breakpoint at Line 45 in EndpointProfileLocation.java to find the localeCountry value retrieved?
Also I don't see a deprecation message for getISO3Country() method? Can you tell me the deprecation message that you're seeing?

@mutablealligator mutablealligator self-assigned this Feb 6, 2019
@Arpanbajpai
Copy link

@kvasukib Sir as requested i attached screenshot with breakpoints and result.I am using API level 28.
i am also not getting any deprecation message but when i tried to log getISO3Country() i got empty string. But using LocaleListCompat list = ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration());
i am able to get "IND".
I tried to search "Locale getISO3Country failed, falling back to getCountry." in logcat but not able to find.

screenshot from 2019-02-07 15-54-46

@mutablealligator
Copy link
Contributor

mutablealligator commented Feb 7, 2019

@Arpanbajpai Thank you for providing me with all the necessary details.

I added few log statements in the code to see if the location is fetched correctly.

    @Test
    public void testUpdateEndpointProfile() {
        EndpointProfile endpointProfile = targetingClient.currentEndpoint();
        EndpointProfileUser endpointProfileUser = new EndpointProfileUser();
        endpointProfileUser.setUserId(credentialsProvider.getIdentityId());
        endpointProfile.setUser(endpointProfileUser);

        targetingClient.updateEndpointProfile();
        assertEquals("The userId should be the Cognito Identity ID",
                credentialsProvider.getIdentityId(),
                targetingClient.currentEndpoint().getUser().getUserId());
        assertNotNull(targetingClient.currentEndpoint().getUser());
        assertNotNull(targetingClient.currentEndpoint().getLocation());
        assertNotNull(targetingClient.currentEndpoint().getDemographic());
        assertNotNull(targetingClient.currentEndpoint().getDemographic().getAppVersion());
        assertNotNull(targetingClient.currentEndpoint().getDemographic().getLocale());
        assertNotNull(targetingClient.currentEndpoint().getDemographic().getMake());
        assertNotNull(targetingClient.currentEndpoint().getDemographic().getModel());
        assertNotNull(targetingClient.currentEndpoint().getDemographic().getPlatform());
        assertNotNull(targetingClient.currentEndpoint().getDemographic().getPlatformVersion());
        assertNotNull(targetingClient.currentEndpoint().getDemographic().getTimezone());

        Log.i(TAG, "Country = " + targetingClient.currentEndpoint().getDemographic().getLocale().getCountry());
    }
02-07 12:01:09.447 4736-4736/com.amazonaws.pinpointinstrumentationtester I/EndpointProfileLocation: Locale getISO3Country(): USA
02-07 12:01:09.675 4736-4758/com.amazonaws.pinpointinstrumentationtester I/EndpointProfileLocation: Locale getISO3Country(): USA
02-07 12:01:09.681 4736-4758/com.amazonaws.pinpointinstrumentationtester I/TargetingInstrumentedTest: Country = US

I am able to retrieve the information on API Level 28 emulator. Can you give some information on the device?

@Arpanbajpai
Copy link

@kvasukib i am using devices of moto(API 25) and redmi(API 24) for testing. It seems it is working pefectly on your side but i am not able to implement it correctly

@samyakjain
Copy link

samyakjain commented Sep 9, 2019

I am also facing the same issue. Why this issue has been closed?

AmazonServiceException occurred during endpoint update: Country should be 2 character ISO 3166-1 Alpha-2 or Alpha-3 codes or UN M.49 numeric-3 area code

    com.amazonaws.services.pinpoint.model.BadRequestException: Country should be 2 character ISO 3166-1 Alpha-2 or Alpha-3 codes or UN M.49 numeric-3 area code (Service: AmazonPinpoint; Status Code: 400; Error Code: BadRequestException; Request ID: 48c67b12-1163-4c2a-b2c5-04a727af01ac)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:730)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:405)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:212)
        at com.amazonaws.services.pinpoint.AmazonPinpointClient.invoke(AmazonPinpointClient.java:4081)
        at com.amazonaws.services.pinpoint.AmazonPinpointClient.updateEndpoint(AmazonPinpointClient.java:3775)
        at com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient$1.run(TargetingClient.java:198)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)```

@Arpanbajpai
Copy link

I am also facing the same issue. Why this issue has been closed?

AmazonServiceException occurred during endpoint update: Country should be 2 character ISO 3166-1 Alpha-2 or Alpha-3 codes or UN M.49 numeric-3 area code

    com.amazonaws.services.pinpoint.model.BadRequestException: Country should be 2 character ISO 3166-1 Alpha-2 or Alpha-3 codes or UN M.49 numeric-3 area code (Service: AmazonPinpoint; Status Code: 400; Error Code: BadRequestException; Request ID: 48c67b12-1163-4c2a-b2c5-04a727af01ac)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:730)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:405)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:212)
        at com.amazonaws.services.pinpoint.AmazonPinpointClient.invoke(AmazonPinpointClient.java:4081)
        at com.amazonaws.services.pinpoint.AmazonPinpointClient.updateEndpoint(AmazonPinpointClient.java:3775)
        at com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient$1.run(TargetingClient.java:198)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)```

Just make sure to insert Locale of your country inside your app.

@samyakjain
Copy link

How to do that? Also what if my app gets downloaded from a different country would that be a problem?

@Arpanbajpai
Copy link

How to do that? Also what if my app gets downloaded from a different country would that be a problem?

While initializing app just declare Locale with country code in your app

@samyakjain
Copy link

Thanks a lot. This solved the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinpoint Issues with the AWS Android SDK for Pinpoint.
Projects
None yet
Development

No branches or pull requests

5 participants