This page applies to Apigee and Apigee hybrid.
View Apigee Edge documentation.
To test the deployed helloworld
API, click the Terminal tab
in Apigee in Cloud Code and enter the following curl call:
curl 0:8998/helloworld
The following error message is displayed:
Because you enabled API key based authentication when creating the API proxy, you need to pass an API key using the apikey
query parameter when calling the API.
To obtain an API key, you need to create a test bundle and configure the following test resources:
API product used to bundle the API and make it available to developers.
Developer that will create an app to access the API.
Developer app that will enable access to the API using an API key.
Build and Export test resources
- Create a test bundle:
- Position your cursor over the tests folder and click .
The Create test bundle wizard opens.
- Enter mytestbundle for the test bundle name and press Enter.
The test bundle is created.
- Expand the mytestbundle folder to view its contents.
- Position your cursor over the tests folder and click .
- Configure the API product test resource:
- Position your cursor over the products.json file and click .
The Create API product wizard opens.
- Enter myproduct for the name of the API product and press Enter to confirm and proceed.
- Enter myproduct for the description of the API product and press Enter to confirm and proceed.
- Select helloworld to add the API proxy to the API product and click OK.
The
products.json
file is opened in the editor with the new API product configured:[ { "attributes": [ { "name": "sample_attribute_0", "value": "sample_attribute_value_0" } ], "scopes": [], "environments": [], "apiResources": [ "/", "/*", "/**" ], "quota": "100", "quotaInterval": "1", "quotaTimeUnit": "minute", "name": "myproduct", "displayName": "myproduct", "proxies": [ "helloworld" ] } ]
- Position your cursor over the products.json file and click .
- Configure the developer test resource:
- Position your cursor over the developers.json file and click .
The Create developer wizard opens.
- Enter the following values at the prompts and press Enter to confirm and proceed:
- Developer email: ahamilton@example.com
- Username: ahamilton
- First name: Alex
- Last name: Hamilton
The
developers.json
file is opened in the editor with the new developer configured:[ { "attributes": [ { "name": "sample_attribute_0", "value": "sample_attribute_value_0" } ], "email": "ahamilton@example.com", "userName": "ahamilton", "firstName": "Alex", "lastName": "Hamilton" } ]
- Position your cursor over the developers.json file and click .
- Configure the developer app test resource:
- Position your cursor over the developerapps.json file and click .
The Create developer app wizard opens.
- Select ahamilton@example.com as the owner of the app.
- Enter the following values at the next set of prompts and press Enter to confirm and proceed:
- App name: myapp
- Description: myapp
- Callback URL: Leave blank
- Select myproduct to add it to the app and click OK.
- Select never for the expiry value.
The
developerapps.json
file is opened in the editor with the new app configured:[ { "attributes": [ { "name": "sample_attribute_0", "value": "sample_attribute_value_0" } ], "developerEmail": "ahamilton@example.com", "name": "myapp", "displayName": "myapp", "callbackUrl": "", "apiProducts": [ "myproduct" ], "expiryType": "never" } ]
- Position your cursor over the developerapps.json file and click .
- Export the test resources to the Apigee Emulator.
Position the cursor over the mytestbundle test bundle and click .
The active test resources appears in the Apigee Emulators section, as shown in the following figure.
Obtain the API key
Obtain the API key credentials for your developer app:
- In the emulators section, under Active test data, click Active developer apps.
The active developer apps configuration file is opened in the editor. The file contains credentials for
myproduct
, as highlighted in the following figure.<p><img src="/apigee/docs/api-platform/images/vscode-consumerkey.png" alt="Developer apps with the consumerKey value highlighted."></p>
- Copy the
consumerKey
value (without the quotes) for themyproduct
API product.
Test your API
Test your API with the API key:
- Pass the API key in your curl call using the
apikey
query parameter, as follows:curl 0:8998/helloworld?apikey=API_KEY
The following response is returned:
Hello, Guest!
Congratulations! You've successfully run an API in your local environment.
In the next step, you'll learn how to change the target endpoint.
1 2 3 4 (NEXT) Step 5: Change the target endpoint 6 7 8