const response = await requestJira(`/jsm/assets/workspace/${workspaceId}/v1/object/create`, {
method: 'POST',
headers: {
'Content-Type': 'application/json', // This is crucial for POST requests with a JSON body
},
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error(`Failed to create object: ${response.status} ${response.statusText}`);
}
always gives 400 Bad Request with a basic HTML document. No further information is given as to why itās a bad request, unusual for the Assets API.
If I copy the request as ācUrl (bash)ā from my browserās devtools network window then follow these steps:
Delete āex/jira/{cloud site UUID}ā from the request URL
Delete the āauthorisationā header
Authorise with my account email and API token, ie. ā-u $FORGE_EMAIL:$FORGE_API_TOKENā
Then when I execute that cUrl command, I get 201 Created and the expected API response.
The app just gets the workspaceId then creates an object, and this time it was 201 Created.
It seems then that the issue has to do with the amount of Oauth scopes in my development app. Iāll likely find it works after I cut out the more obviously extraneous ones.
Thanks for providing this update!
Iāll follow up on this on our end as using fine granular scopes shouldnāt cause a 400 ā or at the very least there should be a developer-friendly error message if thereās a know limitation.
The frontend, that is, client fetch action gives 400 Bad Request, but the backend, that is, invoke resolver action gives 201. Thatās better than previous, where the backend would also give 400 Bad Request.
Here is the TSX component and resolver function that demonstrates this.