0

I have this code that should change the issues of the assignee to another assignee that I selected before.

const changeIssues = async (oldAssignee: User, changeAssignee: User) => {
        setchangeAssigning(true);
        try {
            for (const issues of userIssues) {
                const response = await host.fetchYouTrack(`issues/${issues.id}`, {
                    method: 'POST',
                    headers: {
                        'Accept': 'application/json',
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({
                        customFields: [
                            {
                                name: 'Assignee',
                                $type: 'SingleUserIssueCustomField',
                                value: changeAssignee ? { changeAssignee} : null
                            }
                        ]
                    }),
                }) as Response;
                const result = await response.text();
            }
        } catch (error) {
            console.error('Fehler beim Ändern des Assignees:', error);
            host.alert('Es gab einen Fehler beim Ändern des Assignees.');
        } finally {
            setchangeAssigning(false);
        }
    };

I have changed the fetchYouTrack(issues/${issue.id} to fetchYouTrack(issues/${issue.id}/customFields/Assignee

But I keep getting the error:

POST http://localhost:8080/api/issues/3-32 500 (Server Error)
Fehler beim Ändern des Assignees: 
message
: 
"Request failed."
servlet
: 
"gap-rest-servlet"
status
: 
"500"
url
: 
"/api/issues/3-32"

DevTools Logs: Logs DevTools Server Logs:

WARN - lipse.jetty.server.HttpChannel - /api/issues/3-32/ 
Caused by: javax.ws.rs.ProcessingException: Resource Java method invocation error.

What am I doing wrong?

EDIT:

When I try to change it with the curl command, it works

curl -X POST 'http://localhost:8080/api/issues/3-9?fields=customFields(id,name,value(avatarUrl,buildLink,color(id),fullName,id,isResolved,localizedName,login,minutes,name,presentation,text))' -H 'Accept: application/json' -H 'Authorization: Bearer perm:YWRtaW4=.NDYtMA==.ZffUW8VLlsysJjzbMiC0N3eWWAwILa' -H 'Content-Type: application/json' -d '{ "customFields": [ {"name": "Assignee", "$type": "SingleUserIssueCustomField", "value": {"login": "Test"}}, {"name": "Priority", "$type": "SingleEnumIssueCustomField", "value": {"name": "Major"}} ] }'

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.