ARMmbed

Getenv() can't find API key although API key is defined in project

Hi all,

I have a problem with .env file contain API key. Everytime I call getenv(“API_KEY”), it always return null.

Here is steps to get my api key:

I created an API_KEY.env contain:
MBED_CLOUD_SDK_API_KEY=ak_A644VERY4745LONG64RANDOM3254STRINGW555455ITHA564miXTurOFlowercaseANDUPPERCASELETTERSIintersperseDwithNUMBER5

Then, I put this key in my project. In MainActivity I call System.getenv(“API_KEY”) to get value of environment variable API_KEY.env but it always return null.

Did I have mistake in steps?

I configured follow in this document:
https://armmbed.github.io/mbed-cloud-sdk-documentation/?java#configuration

Please help me! Thanks!
DuyV

Hi,

Can you try getenv(“MBED_CLOUD_SDK_API_KEY”)?
Also, to rule out bad key value, test using curl as outlined here - https://www.pelion.com/docs/device-management/current/integrate-web-app/api-keys.html. Hope this helps.