Skip to content

Commit 7baaf98

Browse files
authored
Merge pull request #229 from microsoftgraph/abhsriva/emptyPostRequest
Post request with empty body, now working fine.
2 parents 2ec9a2f + 2ebf666 commit 7baaf98

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

spec/core/GraphRequestUtil.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ describe("GraphRequestUtil.ts", () => {
6161
node2.link = node1;
6262
try {
6363
serializeContent(node1);
64-
throw new Error("Something wrong with the serialize content, it should stringify cyclic referenced objects");
64+
throw new Error("Something wrong with the serialize content, it should not stringify cyclic referenced objects");
6565
} catch (error) {
6666
assert.equal(error.message, "Unable to stringify the content");
6767
}
6868
});
69+
70+
it("Should return undefined for the case of undefined content value", () => {
71+
const val = undefined;
72+
assert.equal(serializeContent(val), undefined);
73+
});
6974
});
7075
});

src/GraphRequestUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const urlJoin = (urlSegments: string[]): string => {
4141
*/
4242

4343
export const serializeContent = (content: any): any => {
44-
const className: string = content.constructor.name;
44+
const className: string = content === undefined ? undefined : content.constructor.name;
4545
if (className === "Buffer" || className === "Blob" || className === "File" || className === "FormData" || typeof content === "string") {
4646
return content;
4747
}

0 commit comments

Comments
 (0)