[8.18] [Dashboards] Update response on HTTP API should return a 200, not 201 (#217054) (#217494)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Dashboards] Update response on HTTP API should return a 200, not 201
(#217054)](https://github.com/elastic/kibana/pull/217054)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT
[{"author":{"name":"Ola","email":"98127445+olapawlus@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-04-04T17:48:58Z","message":"[Dashboards]
Update response on HTTP API should return a 200, not 201 (#217054)\n\n##
Summary\n\nChanges response from 201 to 200 in the dashboard
updateRoute.\n\nCloses:
#212673","sha":"3c2b4daf97fdaea09cd1cd33b71c561344ec90b0","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Presentation","backport:version","v9.1.0","v8.18.1","v9.0.1","v8.17.5"],"title":"[Dashboards]
Update response on HTTP API should return a 200, not 201
","number":217054,"url":"https://github.com/elastic/kibana/pull/217054","mergeCommit":{"message":"[Dashboards]
Update response on HTTP API should return a 200, not 201 (#217054)\n\n##
Summary\n\nChanges response from 201 to 200 in the dashboard
updateRoute.\n\nCloses:
#212673","sha":"3c2b4daf97fdaea09cd1cd33b71c561344ec90b0"}},"sourceBranch":"main","suggestedTargetBranches":["8.18","9.0","8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217054","number":217054,"mergeCommit":{"message":"[Dashboards]
Update response on HTTP API should return a 200, not 201 (#217054)\n\n##
Summary\n\nChanges response from 201 to 200 in the dashboard
updateRoute.\n\nCloses:
#212673","sha":"3c2b4daf97fdaea09cd1cd33b71c561344ec90b0"}},{"branch":"8.18","label":"v8.18.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Ola Pawlus 2025-04-10 19:19:02 +02:00 committed by GitHub
parent 9001dd9290
commit c744aebc17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View file

@ -175,8 +175,7 @@ export function registerAPIRoutes({
}
return res.badRequest(e.message);
}
return res.created({ body: result });
return res.ok({ body: result });
}
);

View file

@ -14,7 +14,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
describe('main', () => {
it('should return 201 with an updated dashboard', async () => {
it('should return 200 with an updated dashboard', async () => {
const response = await supertest
.put(`${PUBLIC_API_PATH}/be3733a0-9efe-11e7-acb3-3dab96693fab`)
.set('kbn-xsrf', 'true')
@ -45,7 +45,7 @@ export default function ({ getService }: FtrProviderContext) {
],
});
expect(response.status).to.be(201);
expect(response.status).to.be(200);
expect(response.body.item.id).to.be('be3733a0-9efe-11e7-acb3-3dab96693fab');
expect(response.body.item.type).to.be('dashboard');