# Unable to POST to Another Jira Instance using Fetch

**URL:** <https://community.developer.atlassian.com/t/unable-to-post-to-another-jira-instance-using-fetch/83534>\
**Category:** Forge\
**Tags:** forge-fetch, forge-trigger, jira-cloud, rest-api, forge\
**Created:** [September 16, 2024, 12:42pm UTC](https://community.developer.atlassian.com/t/unable-to-post-to-another-jira-instance-using-fetch/83534 "2024-09-16T12:42:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SachinSaini](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@SachinSaini](https://community.developer.atlassian.com/u/SachinSaini)\
**Post date:** [September 16, 2024, 12:42pm UTC](https://community.developer.atlassian.com/t/unable-to-post-to-another-jira-instance-using-fetch/83534/1 "2024-09-16T12:42:55Z")

</div>

I am trying to create a forge request to update data from 1 Jira Cloud instance to another Jira Cloud Instance. I’ve added external.fetch.backend in my manifest file:

```auto
  external:
    fetch:
      backend:
        - 'https://xyz.atlassian.net'

```

Code snippet to update the Issue in Instance 2:

```auto
async function processUpdate(issueKey, fieldMappings, subDomain) {
  const updateBody = JSON.stringify(fieldMappings);

  try {
    const response = await fetch(`https://${subDomain}.atlassian.net/rest/api/3/issue/${issueKey}`, {
      method: "PUT",
      headers: {
        Authorization: `Basic ${Buffer.from(credentials).toString("base64")}`,
        Accept: "application/json",
        "Content-Type": "application/json",
      },
      body: updateBody,
    });

    if (!response.ok) {
      const errorMessage = await response.text();
      throw new Error(`Failed to update issue. Status: ${response.status} ${response.statusText}. Error: ${errorMessage}`);
    }

    console.log(`${response.status} ${response.statusText}`);
  } catch (err) {
    console.error(`Error updating issue ${issueKey}:`, err);
  }
}

```

I am getting the credentials from dotenv.config()  
The app works fine if I am running using Tunnel, but when I install it, it gives below error in the Developer console logs:

```auto
Error updating issue ABC-xx:
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
    at new NodeError (node:internal/errors:405:5)
    at Function.from (node:buffer:325:9)
    at processUpdate (webpack://product-trigger/src/controllers/updateIssue.jsx:38:40)
    at updateIssue (webpack://product-trigger/src/controllers/updateIssue.jsx:28:3)
    at Object.run (webpack://product-trigger/src/index.jsx:35:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async r.<computed> [as handler] (/var/task/index.cjs:2:511237) {
  code: 'ERR_INVALID_ARG_TYPE'
}

```

I tried putting credentials directly as well. Then, it does not give an error, but it does not update the issue in the 2nd instance.

So :  
**1. If I trigger the code using tunnel, it works perfectly.**  
**2. If I trigger it when installed in instance without tunnel, it gives error as I mentioned above.**  
**3. If I directly put the credentials inside Buffer as string, it neither gives an error, not it updates the issue in instance 2.**

How do I make it work?

---

<div class="post-metadata">

**Author:** ![SachinSaini](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@SachinSaini](https://community.developer.atlassian.com/u/SachinSaini)\
**Post date:** [September 16, 2024, 8:13pm UTC](https://community.developer.atlassian.com/t/unable-to-post-to-another-jira-instance-using-fetch/83534/2 "2024-09-16T20:13:11Z")

</div>

SOLVED: Very Basic Mistake by me, Just needed to put Authorization under quotes. That’s it!
