Step 4: Change the target endpoint

This page applies to Apigee and Apigee hybrid.

View Apigee Edge documentation.

Now that you've tested your new proxy, you're almost ready to add a policy to it. Before you do that, though, change your proxy's target endpoint to one that returns some data.

Recall that in Step 1: Create an API proxy, you set the target endpoint (in the Existing API field) to https://mocktarget.apigee.net. Suppose that endpoint didn't return any interesting data. Then you can change the endpoint to one that does return some useful XML. This section explains how to do so.

New Proxy Editor

You can change a proxy's target endpoint in the Develop view of the Proxy Editor. To open the Develop view:

  1. Select Develop > API Proxies and in the Proxies pane, select the environment for the proxy.

  2. In the proxies list, select the proxy myproxy, which you created in Step 1: Create an API proxy.
  3. Click the Develop tab to display the Develop view:

    Develop view in the Proxy Editor

Develop view

In the left-hand pane of the Develop view, you can:

  • Search for text in the proxy in the Search proxy field.
  • Add new policies.
  • Add proxy and target endpoints.
  • Add other resources.

If you don't want to view the left-hand pane, you can collapse it by clicking the close button Close search pane button..

The right-hand pane of the Develop view displays the visual and text editors for the proxy:

  • The visual editor provides a graphical view of the request and response flow.
  • The text editor lets you edit the XML for the proxy or target.

Visual and text editors with selectable divider.

Notes:

  • You can click and drag the divider between the two editors up or down to expand the display area of either editor.
  • You can expand the display area of the visual editor by clicking the toggle button on the right side of the text editor, which closes the text editor pane. Click the toggle button again to re-open the text editor pane.

Change the target endpoint

To change the target endpoint of the proxy:

  1. In the Proxy revision pane, select Target Endpoints > default.

    Target endpoints selected in the Proxy Explorer.

    This displays a diagram of the target endpoint in the visual editor:

    Target endpoints selected in the Proxy Explorer.

    Below the visual editor, the XML code for the target endpoint is displayed in the text editor:

    XML for target endpoint displayed in text editor.

  2. In the text editor, change the <URL> to https://mocktarget.apigee.net/xml. (Append "/xml" to the existing URL.)

    The new URL is shown below:

    ...
    <HTTPTargetConnection>
      <Properties/>
      <URL>https://mocktarget.apigee.net/xml</URL>
    </HTTPTargetConnection>
    ...
  3. Click the arrow next to Save at the top right of the Proxy Editor, and select Save as new revision.
  4. To deploy your changes, click Deploy.
  5. In the Deploy dialog, select the revision and environment in which to deploy, and click Deploy.

Classic Proxy Editor

To change your proxy's target endpoint:

  1. Sign in to the Apigee UI.
  2. Select Develop > API Proxies.
  3. Select your proxy from the list to display the API proxy details. If you don't see your proxy in the list, be sure that you selected the right organization, as described in Switching between your organizations.
  4. Click the Develop tab:

    Develop tab.

    This takes you to the API Proxy Editor. The Proxy Editor lets you see the structure of your API proxy and configure its flow. (A flow is just the stepwise path an API proxy request takes through the Apigee platform. Other tutorials will cover the concept of flows.)

  5. In the Navigator pane, select Target Endpoints > default > PreFlow:

    Apigee displays the endpoint settings in the Code pane:

    <TargetEndpoint name="default">
      <Description/>
      <FaultRules/>
      <PreFlow name="PreFlow">
        <Request/>
        <Response/>
      </PreFlow>
      <PostFlow name="PostFlow">
        <Request/>
        <Response/>
      </PostFlow>
      <Flows/>
      <HTTPTargetConnection>
        <Properties/>
        <URL>https://mocktarget.apigee.net</URL>
      </HTTPTargetConnection>
    </TargetEndpoint>

    The target endpoint is defined by the <HTTPTargetConnection> element.

  6. Change the URL to "https://mocktarget.apigee.net/xml". (Append "/xml" to the existing URL.)

    The new URL returns a small block of XML in the body of the response.

    Your endpoint configuration should now look like the following:

    ...
    <HTTPTargetConnection>
      <Properties/>
      <URL>https://mocktarget.apigee.net/xml</URL>
    </HTTPTargetConnection>
    ...
  7. To save your changes to the proxy configuration, click the Save button.

    Apigee saves your changes in a new proxy revision.

  8. To deploy the new revision, select Deploy to: test and click Deploy 2.
  9. In the confirmation dialog, click Deploy.

    If there is an error, Apigee will save your changes but not deploy the proxy. In the case of an error:

    1. Fix your proxy configuration. Apigee may provide syntax guidance as a pop-up.
    2. Manually deploy your changes to the test environment by clicking Deployment > test if Apigee does not automatically deploy it.

    You can check if your proxy revision was deployed successfully by viewing the deployment revision status adjacent to the Deploy drop-down. For example:

Test the proxy

You can test your changes by sending a request to your proxy, just as you did in Call your API proxy. The following example assumes that the proxy is named myproxy:

curl https://YOUR_ENV_GROUP_HOSTNAME/myproxy

where YOUR ENV_GROUP_HOSTNAME is the environment group hostname. See Find the environment group hostname.

This time, the mocktarget endpoint returns XML in the body of the response:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <city>San Jose</city>
  <firstName>John</firstName>
  <lastName>Doe</lastName>
  <state>CA</state>
</root>

Now that the API proxy returns XML data, in the next step you will add a policy that converts XML to JSON.

1 2 3 4 (NEXT) Step 5: Add a policy