Huawei Nearby Search Error BUSINESS_VERIFICATION_FAILED

Viewed 57

I have been using Site kit service to get nearby locations on the biases of Lat Lng. But unfortunately this error appears out of no where. error log

I had studied the documentation and error code which explain this error code description

But the searched parameters are all those which are provided in documentations(for testing purpose) except the api key.

val searchService: SearchService = SearchServiceFactory.create(
        this, URLEncoder.encode(
            getString(R.string.huawei_maps_key),
            "UTF-8"
        )
    )
    val request = NearbySearchRequest()
    val location = Coordinate(48.893478, 2.334595)
    request.location = location
    request.query = "Paris"
    request.radius = 1000
    request.hwPoiType = HwLocationType.ADDRESS
    request.language = "fr"
    request.pageIndex = 1
    request.pageSize = 5
    request.strictBounds = false
1 Answers

Try to change your following code

val searchService: SearchService = SearchServiceFactory.create(
        this, URLEncoder.encode(
            getString(R.string.huawei_maps_key),
            "UTF-8"
        )
    )

to:

   val apiKey: String?
        get() {
            // get apiKey from AppGallery Connect
            val apiKey = "your api key"

            // need encodeURI the apiKey
            return try {
                URLEncoder.encode(apiKey, "utf-8")
            } catch (e: UnsupportedEncodingException) {
                Log.e(TAG, "encode apikey error")
                null
            }
        }


searchService = SearchServiceFactory.create(this, apikey)
Related