> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/internal-developer-portal/troubleshooting-and-resources/knowledge-base/articles/backend-proxies/harness-code.md).

# Harness Code Files

### Overview <a href="#overview" id="overview"></a>

Instead of using an API to retrieve JSON data with a backend proxy, we can store JSON files in Harness Code and use an HTTP call to get the raw file back as pure JSON.

### Setup <a href="#setup" id="setup"></a>

First enable the `Configure Backend Proxies` [plugin](/internal-developer-portal/use-idp/plugins/overview.md) in your IDP instance.

Once enabled, go to the plugins page and select the `Configure Backend Proxies` plugin to view its configuration.

The following is a proxy definition to resolve raw files from GitHub:

```yaml
proxy:
  endpoints:
    /harness-code:
      target: https://app.harness.io/gateway/code/api/v1/repos/<your harness account id>/
      pathRewrite: 
        /api/proxy/harness-code/?: /
      headers:
        x-api-key: ${PROXY_HARNESS_TOKEN}
```

What we are doing here is:

1. Declaring a proxy called `harness-code`
2. Targeting a base URL of `https://app.harness.io/gateway/code/api/v1/repos/<your harness account id>/`
3. Rewriting any request from `/api/proxy/harness-code/` to `app.harness.io/gateway/code/api/v1/repos/<your harness account id>/` and appending anything after `harness-code/` to the `app.harness.io/` URL
4. Passing an authentication header using the variable `PROXY_HARNESS_TOKEN`

We will need to create a variable below called `PROXY_HARNESS_TOKEN` and select the Harness account secret that holds the value. This needs to be a Harness API key with read access to Code repos, preferably from a service account, that can resolve files from your target repositories.

After configuring the above your plugin configuration should look like this:

![](/files/1ajTpxqw8wJ5d7GHxKjt)

### Usage <a href="#usage" id="usage"></a>

Now that we have the proxy defined, we can use it in a workflow definition to retrieve JSON values to be used in a dropdown picker.

Before, you might have had a parameter with the following hard-coded list of options:

```yaml
properties:
  some-property:
    type: string
    title: Some Property
    enum:
      - item1
      - item2
```

Now with our custom backend for Harness Code raw files, we can query GitHub to get our JSON and pull out the relevant keys to show as options in our picker:

```yaml
properties:
  some-property:
    type: string
    ui:field: SelectFieldFromApi
    ui:options:
      title: Some Property
      description: An input for users to select
      path: "proxy/harness-code/<harness org id>/<harness project id>/<repo name>/+/raw/<path to json>"
```

The above is if your JSON is a simple list of values:

```
["item1", "item2"]
```

If you have complex JSON you can follow the usage pattern [described here](/internal-developer-portal/use-idp/self-service-workflows/workflows-tutorials/dynamic-picker.md#parsing-api-response-using-filters).

### Alternative configurations <a href="#alternative-configurations" id="alternative-configurations"></a>

If you do not want to have to pass the organization and project identifier in every workflow, or you want to lock the proxy down to a specific org, project, or repo, we can just add more of the URL to the proxy config, and pass less in the picker path.

#### Organization specific <a href="#organization-specific" id="organization-specific"></a>

Proxy config:

```
proxy:
  endpoints:
    /harness-code:
      target: https://app.harness.io/gateway/code/api/v1/repos/<your harness account id>/<harness org id>/
```

Usage:

```yaml
properties:
  some-property:
    type: string
    ui:field: SelectFieldFromApi
    ui:options:
      title: Some Property
      description: An input for users to select
      path: "proxy/harness-code/<harness project id>/<repo name>/+/raw/<path to json>"
```

#### Project specific <a href="#project-specific" id="project-specific"></a>

Proxy config:

```
proxy:
  endpoints:
    /harness-code:
      target: https://app.harness.io/gateway/code/api/v1/repos/<your harness account id>/<harness org id>/<harness project id>/
```

Usage:

```yaml
properties:
  some-property:
    type: string
    ui:field: SelectFieldFromApi
    ui:options:
      title: Some Property
      description: An input for users to select
      path: "proxy/harness-code/<repo name>/+/raw/<path to json>"
```

#### Repository specific <a href="#repository-specific" id="repository-specific"></a>

Proxy config:

```
proxy:
  endpoints:
    /harness-code:
      target: https://app.harness.io/gateway/code/api/v1/repos/<your harness account id>/<harness org id>/<harness project id>/<repo name>/+/raw/
```

Usage:

```yaml
properties:
  some-property:
    type: string
    ui:field: SelectFieldFromApi
    ui:options:
      title: Some Property
      description: An input for users to select
      path: "proxy/harness-code/<path to json>"
```

### Conclusion <a href="#conclusion" id="conclusion"></a>

With the above backend proxy, you can store raw JSON in Code and reference it across your IDP workflows. This is especially useful if you have common sets of inputs you need to use across many workflows and want to have a single source of truth.
