# Cannot get Forge Attachment Count Custom Field example to work

**URL:** <https://community.developer.atlassian.com/t/cannot-get-forge-attachment-count-custom-field-example-to-work/83644>\
**Category:** Forge Rookies\
**Created:** [September 19, 2024, 2:17pm UTC](https://community.developer.atlassian.com/t/cannot-get-forge-attachment-count-custom-field-example-to-work/83644 "2024-09-19T14:17:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KelpMine](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@KelpMine](https://community.developer.atlassian.com/u/KelpMine)\
**Post date:** [September 19, 2024, 2:17pm UTC](https://community.developer.atlassian.com/t/cannot-get-forge-attachment-count-custom-field-example-to-work/83644/1 "2024-09-19T14:17:31Z")

</div>

I am trying to run this example:  
[https://bitbucket.org/atlassian/forge-attachment-count-custom-field/src/master/](https://bitbucket.org/atlassian/forge-attachment-count-custom-field/src/master/)

When I run the web trigger with this command:

```auto
curl -X POST <url> -H "Content-Type: application/json" -d '{"startAt":0, "maxResults": 1000}'

```

I get the following error:

```auto
{"timestamp":"2024-09-19T14:07:48.478+00:00","path":"/x1/_kbc2N2bDYqdgxkcLB470IVc7EY","status":424,"error":"Failed Dependency","requestId":"24796d3c-858976"

```

and in the tunnel, I get the following:

```auto
INFO 16:07:14.426 ab72e692-8a7f-4da5-8564-81bc8f1b885f REQUEST: POST [object Object] {"expression":"issues.reduce((acc, i) => acc.set(i.attachments.length+'', (acc[i.attachments.length+''] || []).concat(i.id)), {})","context":{"issues":{"jql":{"query":"order by id","startAt":0,"maxResults":1000}}}}
ERROR 16:07:14.904 ab72e692-8a7f-4da5-8564-81bc8f1b885f FetchError: invalid json response body at https://jira/rest/api/2/expression/eval reason: Unexpected end of JSON input
    at <anonymous> (webpack://jira-custom-field-ui-kit-2/node_modules/node-fetch/lib/index.mjs:267:1)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.setUpAttachmentCount (webpack://jira-custom-field-ui-kit-2/src/attachments.js:20:1)
    at async /tmp/tunnel-563429-mfUk0COR6kbp/attachments.cjs:2:511617
    at async process.<anonymous> (/home/anders/.nvm/versions/node/v20.17.0/lib/node_modules/@forge/cli/node_modules/@forge/tunnel/out/sandbox/sandbox-runner.js:7:20) {
  type: 'invalid-json'
}

```

Does anyone have an idea to what I am doing wrong?

Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![JP11](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@JP11](https://community.developer.atlassian.com/u/JP11)\
**Post date:** [September 26, 2024, 11:26pm UTC](https://community.developer.atlassian.com/t/cannot-get-forge-attachment-count-custom-field-example-to-work/83644/2 "2024-09-26T23:26:48Z")

</div>

Having the same issue when I tried the following tutorial  
[https://developer.atlassian.com/platform/forge/automate-bitbucket-using-triggers/](https://developer.atlassian.com/platform/forge/automate-bitbucket-using-triggers/)

```auto
ERROR 16:13:19.240 xxxxx-xxxx-xxxxxx FetchError: invalid json response body at https://forge-outbound-proxy.services.atlassian.com/fpp/provider/app/remote/bitbucket reason: Unexpected token 'P', "Proxy Auth"... is not valid JSON
    at <anonymous> (webpack://product-trigger/node_modules/node-fetch/lib/index.mjs:267:1)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at addComment (webpack://product-trigger/src/index.jsx:22:1)
    at Object.run (webpack://product-trigger/src/index.jsx:28:1)
    at async /private/var/folders/_6/811c1kx57tj6lmr_cw3l9lm40000gn/T/tunnel-87660-MRcn3EnYPj7h/index.cjs:2:511617
    at async process.<anonymous> (/usr/local/lib/node_modules/@forge/cli/node_modules/@forge/tunnel/out/sandbox/sandbox-runner.js:7:20) {
  type: 'invalid-json'
}

```

---

<div class="post-metadata">

**Author:** ![HelenOBoyle](https://avatars.discourse-cdn.com/v4/letter/h/e79b87/32.png) [@HelenOBoyle](https://community.developer.atlassian.com/u/HelenOBoyle)\
**Post date:** [October 24, 2024, 3:11am UTC](https://community.developer.atlassian.com/t/cannot-get-forge-attachment-count-custom-field-example-to-work/83644/3 "2024-10-24T03:11:56Z")

</div>

Hi KelpMine!

Welcome to for Forge developer community.

Since the example you were looking at works with attachments, your app might have run into an egress permission issue for the URL associated with attachments. Per the Forge changelog, Forge was updated in October so that apps now automatically have egress permission to the attachments URL.

Try this:

1. Pick up the latest version of the Forge CLI with `npm install -g @forge/cli@latest`
2. Get the latest Forge API package, from your app’s root folder, with `npm install @forge/api@latest`

If your manifest still uses the old sandbox runtime, you may also need to update the `app` entry in it to the latest runtime, as follows:

```auto
app:
  runtime:
    name: nodejs18.x
  id: your-app-id-here

```

Let us know if this helps.
