Removing user from a group returns 400 via REST API

Hi, I want my app to remove users from selected group(s) but Jira REST API returns status 400 SyntaxError: Unexpected end of JSON input.
Here is my code:

import API, { route } from "@forge/api";
API.asApp().requestJira(
        route`/rest/api/3/group/user?groupname=${groupname}&accountId=${accountId}`,
        {
          method: "DELETE",
        },
      );

Hi @yagizhan14 ,
Did you check the request in Postman or sth similar?

Hi @MagdalenaRogulska , I made the same request with Postman and it was successful.

@yagizhan14 could you show the actual code of your app, specifically the part where it logs the 400 status and the SyntaxError: Unexpected end of JSON input error message?

Hey @yagizhan14,

The error you experience is most likely related to the empty body in the response (which ends with 200 status code). The solution would be to process the response as text and not as a json e.g.

const request = await api.asUser().requestJira(route`/rest/xxxxxx`);
const result = await request.text();

Thanks,
Vitalii

2 Likes