Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Response 204 with "" instead of null #256

@Abrissirba

Description

@Abrissirba

Category

[ ] Enhancement

[ *] Bug

[ ] Question

Expected / Desired Behavior / Question

pnp.sp.crossDomainWeb(this.sharePointConfigService.addInWebUrl, this.sharePointConfigService.hostWebUrl).getFileByServerRelativeUrl(serverRelativeUrl).setContent(content); should update the content of the file without throwing an exception.

Observed Behavior

ConvertToResponse in this file, https://github.com/SharePoint/PnP-JS-Core/blob/master/src/net/sprequestexecutorclient.ts, throws an exception in chrome because the body is "" when it should be null when the status is 204. Not sure if this should be considered as a bug in pnp-js-core or SP.RequestExecutor.js.

I solved it temporarily with this code:
var body = spResponse.statusCode === 204 && spResponse.body === "" ? null : spResponse.body;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions