Get all Customer Request Types api endpoint only returns the response code and response status

I’ve been trying to gather the content from the following request endpoint, but it keeps getting me only the “response code” and “response status”:

const response = await api.asApp().requestJira(route`/rest/servicedeskapi/requesttype`, {
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
            'X-ExperimentalApi': 'opt-in'
        }
    });

Whenever I try to access the response value, it just returns

{"headers":{},"ok":true,"status":200,"statusText":"OK"}

No clue on where the actual response gets lost:

Have you faced anything similar to this?

Welcome to the Atlassian Developer Community, @vicktorjunior!

I have tried the said API using Forge and it is behaving as expected. How are you referencing the response value in your code, can you share a snippet?

Here’s a snippet on what I did and you can try using it to compare with yours

  const res = await api.asApp().requestJira(route`/rest/servicedeskapi/requesttype`, {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
      "Accept": "application/json",
      "X-ExperimentalApi": "opt-in"
    }
  });
  // If you did this, this could explain the response you are getting
  console.log("If you did this, this could explain the response you are getting");
  console.log(res);

  // This route should give you the expected response
  const data = await res.json();
  console.log(data);

Hope this helps and let us know how it goes.

Ian

Hi Ian,

This is the snippet of the code that I’m using to access the data:

const fetchRequestTypes = async function (context) {
    const body = {}
    const response = await api.asApp().requestJira(route`/rest/servicedeskapi/requesttype`, {
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
            'X-ExperimentalApi': 'opt-in'
        }
    });
    const data = await response.json();
    console.log((data));

    return data.size;
}

And this is the output on the plugin screen:
image

It seems to be working fine now.

Now, how can I access stuff such as the id from the request type on the list of request types?
I’d need this information in order to be able of compiling the URL to dynamically generate access the request types.