Issue/createmeta expand parameter doesn't work

I’m trying to use the /rest/api/3/issue/createmeta api in a Forge app, but i can’t seem to “expand” the results. Using the bare /rest/api/3/issue/createmeta doesn’t give anything expanded like in the documentation. Adding the “expand=projects.issuetypes.fields” parameter doesn’t do anything better.

Can someone point to what I’m missing/not have correct?

const fetchCreateMetadata = async () => {
	
	const response = await api.asUser().requestJira(route`/rest/api/3/issue/createmeta?projectIds=10128&issuetypeIds=10093,10075,10000&expand=projects.issuetypes.fields`, {
	headers: {
		'Accept': 'application/json'
	}
	});

	console.log(`Response: ${response.status} ${response.statusText}`);
	console.log(await response.json());
}

and the response is

INFO    18:07:24.975  be1dde19dfbc4793  Response: 200 OK
INFO    18:07:25.000  be1dde19dfbc4793  {
  expand: 'projects',
  projects: [
    {
      expand: 'issuetypes',
      self: 'https://api.atlassian.com/ex/jira/e27a08c6-2e7a-4e3c-be37-175d4c34edef/rest/api/3/project/10128',
      id: '10128',
      key: 'CET',
      name: 'Charlie Errata Test',
      avatarUrls: [Object],
      issuetypes: [Array]
    }
  ]
}

Hi @CharlieLenahan. Check out the docs on how to put query parameters into an API request in Forge. https://developer.atlassian.com/platform/forge/runtime-reference/product-fetch-api/#route

The route tagged template literal strips everything after the ? in each parameter to prevent query string injection attacks in Forge apps. You will need to make a query where the ? is not part of the interpolated parameters.

In your case, you’ll need to do something like this: (and obviously have values set in those placeholder variables)

const response = await api.asUser().requestJira(route`/rest/api/3/issue/createmeta?projectIds=${projectIds}&issuetypeIds=${issueTypeIds}&expand=${expands}`, {
headers: {
	'Accept': 'application/json'
}
});

Thanks for your response. I do that on my other functions (because they’re reusable), but didn’t know its a requirement, so i’ll keep that in mind.

I’ve changed my code, but I still can’t get it expand to see the fields. i’ve tried different permutations of having the projectIds/issuetypeIds , and those are able to filter the response (though so did my original code).

const fetchCreateMetadata = async () => {
	let projectIds="10128"
	let issuetypeIds="10093";
	let expand="projects.issuetypes.fields";

	console.log(`/rest/api/3/issue/createmeta?projectIds=${projectIds}&issuetypeIds=${issuetypeIds}&expand=${expand}`)

	const response = await api.asUser().requestJira(route`/rest/api/3/issue/createmeta?projectIds=${projectIds}&issuetypeIds=${issuetypeIds}&expand=${expand}`, {
		headers: {
		'Accept': 'application/json'
	}
	});

	console.log(`CreateMeta Response: ${response.status} ${response.statusText}`);
	console.log(await response.json());
}
INFO    17:31:04.388  82be4d6783afeb35  CreateMeta Response: 200 OK
INFO    17:31:04.404  82be4d6783afeb35  {
  expand: 'projects',
  projects: [
    {
      expand: 'issuetypes',
      self: 'https://api.atlassian.com/ex/jira/e27a08c6-2e7a-4e3c-be37-175d4c34edef/rest/api/3/project/10128',
      id: '10128',
      key: 'CET',
      name: 'Charlie Errata Test',
      avatarUrls: [Object],
      issuetypes: [Array]
    }
  ]
}

@CharlieLenahan,

On one hand, Create Issue Meta Endpoint Deprecation should be pretty easy to pick up since there is a new endpoint matching your way of asking for the data by project and id:

Since the fields are expanded by default, you should get what you want with less struggle against the Forge route macro. Hope that helps.