384
385
async writeResource(resource: ServerResource, data: string, ref: string | null, collection?: string, headers: IHeaders = {}): Promise<string> {
387
throw new Error('No settings sync store url configured.');
388
}
390
>
const url = this.getResourceUrl(this.userDataSyncStoreUrl, collection, resource).toString();
391
>
headers = { ...headers };
392
>
headers['Content-Type'] = Mimes.text;
393
>
if (ref) {
394
headers['If-Match'] = ref;
395
}
397
>
const context = await this.request(url, { type: 'POST', data, headers, callSite: 'userDataSync.writeResource' }, [], CancellationToken.None);
398
>
399
>
const newRef = context.res.headers['etag'];
400
>
if (!newRef) {
401
throw new UserDataSyncStoreError('Server did not return the ref', url, UserDataSyncErrorCode.NoRef, context.res.statusCode, context.res.headers[HEADER_OPERATION_ID]);
402
}
404
>
}
405
406
// #endregion