Skip to content

Commit c77ac8a

Browse files
author
Joenio Marques da Costa
committed
fix dataset update endpoint according to Native API spec
reference: https://guides.dataverse.org/en/latest/api/native-api.html#publish-a-dataset
1 parent 53b1909 commit c77ac8a

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/dataverseClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export class DataverseClient {
169169
}
170170

171171
public async publishDataset(datasetId: string, versionUpgradeType: DatasetVersionUpgradeType = DatasetVersionUpgradeType.MAJOR): Promise<AxiosResponse> {
172-
const url = `${this.host}/api/datasets/${datasetId}/actions/:publish?type=${versionUpgradeType}`
172+
const url = `${this.host}/api/datasets/:persistentId/actions/:publish?persistentId=${datasetId}&type=${versionUpgradeType}`
173173
return this.postRequest(url, '')
174174
}
175175

test/dataverseClient.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ describe('DataverseClient', () => {
13371337

13381338
assert.calledOnce(axiosPostStub)
13391339
assert.calledWithExactly(axiosPostStub,
1340-
`${host}/api/datasets/${datasetId}/actions/:publish?type=${DatasetVersionUpgradeType.MINOR}`,
1340+
`${host}/api/datasets/:persistentId/actions/:publish?persistentId=${datasetId}&type=${DatasetVersionUpgradeType.MINOR}`,
13411341
JSON.stringify(''),
13421342
{ headers: { 'X-Dataverse-key': apiToken } })
13431343
})
@@ -1347,7 +1347,7 @@ describe('DataverseClient', () => {
13471347
await client.publishDataset(datasetId, DatasetVersionUpgradeType.MINOR)
13481348

13491349
assert.calledOnce(axiosPostStub)
1350-
assert.calledWithExactly(axiosPostStub, `${host}/api/datasets/${datasetId}/actions/:publish?type=${DatasetVersionUpgradeType.MINOR}`,
1350+
assert.calledWithExactly(axiosPostStub, `${host}/api/datasets/:persistentId/actions/:publish?persistentId=${datasetId}&type=${DatasetVersionUpgradeType.MINOR}`,
13511351
JSON.stringify(''),
13521352
{ headers: { 'X-Dataverse-key': '' } })
13531353
})
@@ -1359,7 +1359,7 @@ describe('DataverseClient', () => {
13591359
'test': randomValue
13601360
}
13611361
axiosPostStub
1362-
.withArgs(`${host}/api/datasets/${datasetId}/actions/:publish?type=${DatasetVersionUpgradeType.MINOR}`, JSON.stringify(''), { headers: { 'X-Dataverse-key': apiToken } })
1362+
.withArgs(`${host}/api/datasets/:persistentId/actions/:publish?persistentId=${datasetId}&type=${DatasetVersionUpgradeType.MINOR}`, JSON.stringify(''), { headers: { 'X-Dataverse-key': apiToken } })
13631363
.resolves({ ...mockResponse, 'test': randomValue })
13641364

13651365
const response = await client.publishDataset(datasetId, DatasetVersionUpgradeType.MINOR)
@@ -1388,7 +1388,7 @@ describe('DataverseClient', () => {
13881388

13891389
assert.calledOnce(axiosPostStub)
13901390
assert.calledWithExactly(axiosPostStub,
1391-
`${host}/api/datasets/${datasetId}/actions/:publish?type=${DatasetVersionUpgradeType.MAJOR}`,
1391+
`${host}/api/datasets/:persistentId/actions/:publish?persistentId=${datasetId}&type=${DatasetVersionUpgradeType.MAJOR}`,
13921392
JSON.stringify(''),
13931393
{ headers: { 'X-Dataverse-key': apiToken } })
13941394
})
@@ -1398,7 +1398,7 @@ describe('DataverseClient', () => {
13981398
await client.publishDataset(datasetId, DatasetVersionUpgradeType.MAJOR)
13991399

14001400
assert.calledOnce(axiosPostStub)
1401-
assert.calledWithExactly(axiosPostStub, `${host}/api/datasets/${datasetId}/actions/:publish?type=${DatasetVersionUpgradeType.MAJOR}`,
1401+
assert.calledWithExactly(axiosPostStub, `${host}/api/datasets/:persistentId/actions/:publish?persistentId=${datasetId}&type=${DatasetVersionUpgradeType.MAJOR}`,
14021402
JSON.stringify(''),
14031403
{ headers: { 'X-Dataverse-key': '' } })
14041404
})
@@ -1410,7 +1410,7 @@ describe('DataverseClient', () => {
14101410
'test': randomValue
14111411
}
14121412
axiosPostStub
1413-
.withArgs(`${host}/api/datasets/${datasetId}/actions/:publish?type=${DatasetVersionUpgradeType.MAJOR}`, JSON.stringify(''), { headers: { 'X-Dataverse-key': apiToken } })
1413+
.withArgs(`${host}/api/datasets/:persistentId/actions/:publish?persistentId=${datasetId}&type=${DatasetVersionUpgradeType.MAJOR}`, JSON.stringify(''), { headers: { 'X-Dataverse-key': apiToken } })
14141414
.resolves({ ...mockResponse, 'test': randomValue })
14151415

14161416
const response = await client.publishDataset(datasetId, DatasetVersionUpgradeType.MAJOR)
@@ -1440,7 +1440,7 @@ describe('DataverseClient', () => {
14401440

14411441
assert.calledOnce(axiosPostStub)
14421442
assert.calledWithExactly(axiosPostStub,
1443-
`${host}/api/datasets/${datasetId}/actions/:publish?type=${DatasetVersionUpgradeType.MAJOR}`,
1443+
`${host}/api/datasets/:persistentId/actions/:publish?persistentId=${datasetId}&type=${DatasetVersionUpgradeType.MAJOR}`,
14441444
JSON.stringify(''),
14451445
{ headers: { 'X-Dataverse-key': apiToken } })
14461446
})
@@ -1450,7 +1450,7 @@ describe('DataverseClient', () => {
14501450
await client.publishDataset(datasetId)
14511451

14521452
assert.calledOnce(axiosPostStub)
1453-
assert.calledWithExactly(axiosPostStub, `${host}/api/datasets/${datasetId}/actions/:publish?type=${DatasetVersionUpgradeType.MAJOR}`,
1453+
assert.calledWithExactly(axiosPostStub, `${host}/api/datasets/:persistentId/actions/:publish?persistentId=${datasetId}&type=${DatasetVersionUpgradeType.MAJOR}`,
14541454
JSON.stringify(''),
14551455
{ headers: { 'X-Dataverse-key': '' } })
14561456
})
@@ -1462,7 +1462,7 @@ describe('DataverseClient', () => {
14621462
'test': randomValue
14631463
}
14641464
axiosPostStub
1465-
.withArgs(`${host}/api/datasets/${datasetId}/actions/:publish?type=${DatasetVersionUpgradeType.MAJOR}`, JSON.stringify(''), { headers: { 'X-Dataverse-key': apiToken } })
1465+
.withArgs(`${host}/api/datasets/:persistentId/actions/:publish?persistentId=${datasetId}&type=${DatasetVersionUpgradeType.MAJOR}`, JSON.stringify(''), { headers: { 'X-Dataverse-key': apiToken } })
14661466
.resolves({ ...mockResponse, 'test': randomValue })
14671467

14681468
const response = await client.publishDataset(datasetId)

0 commit comments

Comments
 (0)