Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions pages/pmProjectsAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export class PMProjectsAPI {
getProjectByTitleAPI(projectTitle) {
return cy.window().then(win => {
return win.ProcessMaker.apiClient.get('/projects', { params: { title: projectTitle } }).then(response => {
const project = response.data.data.find(project => project.title === projectTitle);
return project;
});
});
}

createProjectAPI(payload, ignoreTakenError) {
const formData = new FormData();
formData.append('title', payload.title);
formData.append('categories', payload.categories);
formData.append('user_id', payload.user_id);
formData.append('members', payload.members);
return cy.window().then(win => {
return win.ProcessMaker.apiClient.post('/projects', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: FormData Bug: Manual Content-Type Overwrites Boundary

Manually setting the Content-Type header to 'multipart/form-data' when using FormData prevents the browser from automatically including the necessary boundary parameter. This causes the server to be unable to parse the request body, leading to API request failures.

Fix in Cursor Fix in Web

}).then(response => {
return response.data;
}).catch(err => {
if (ignoreTakenError && err.response.data.message.toLowerCase() === 'the name has already been taken.') {
return this.getProjectByTitleAPI(payload.title);
} else {
throw err;
}
});
});
}
}