Can't resolve api.atlassian.com from Forge resolver?

I’m developing a Forge app that uses a backend resolver to request object data from the asset database. I am attempting to make the POST object aql request but the function can’t resolve api.atlassian.com

Welcome to the Atlassian developer community @mikeeder,

Can you provide more context about how you are making that request? What’s the code for that function?

@ibuchanan I’m using the fetch API, here is a snippet of the request code:

    // https://developer.atlassian.com/cloud/assets/rest/api-group-object/#api-object-aql-post
    const url = `https://api.atlassian.com/jsm/assets/workspace/${config.WorkspaceId}/v1/object/aql?maxResults=500`;

    const body = {
        qlQuery: "objectType in (\"Product Title\", \"Platforms\", \"Environment\", \"Service\", \"Studio Name\")"
    };

    const options = {
        method: 'POST',
        headers: {
            'Authorization': 'Basic ' + Buffer.from(config.AuthUsername + ":" + config.AuthPassword).toString('base64'),
            'Content-Type': 'application/json',
        },
        redirect: 'follow' as RequestRedirect,
        body: JSON.stringify(body),
    };

    const response = await fetch(url, options);
    const jsonData = await response.json();

I’ve got the api.atlassian.com domain in my manifest.yml as well:

  external:
    fetch:
      backend:
        - "api.atlassian.com"

Turns out I missed the fetch import from forge:

import { fetch } from "@forge/api";

The builtin node fetch apparently isn’t able to resolve domains the same as the forge fetch :man_facepalming:

1 Like