File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
src/publish/confluence/api Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -381,10 +381,19 @@ export class ConfluenceClient {
381
381
} ;
382
382
}
383
383
384
- private handleResponse < T > ( response : Response ) {
384
+ private async handleResponse < T > ( response : Response ) {
385
385
if ( response . ok ) {
386
386
if ( response . body ) {
387
- return response . json ( ) as unknown as T ;
387
+ // Some Confluence API endpoints return successfull calls with no body while using content-type "application/json"
388
+ // example: https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content-restrictions/#api-wiki-rest-api-content-id-restriction-byoperation-operationkey-bygroupid-groupid-get
389
+ // To prevent JSON parsing errors we have to return null for empty bodies and only parse when there is content
390
+ let data = await response . text ( ) ;
391
+
392
+ if ( data === "" ) {
393
+ return null as unknown as T ;
394
+ } else {
395
+ return JSON . parse ( data ) as unknown as T ;
396
+ }
388
397
} else {
389
398
return response as unknown as T ;
390
399
}
You can’t perform that action at this time.
0 commit comments