Multiple headers only take the last one

Open
#1,048 18 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

Assessment

This issue has not been assessed yet.

Description

Needs: Attention :wave: question

Bug Report

Prerequisites

  • Can you reproduce the problem?
  • Are you running the latest version?
  • Are you reporting to the correct repository?
  • Did you perform a cursory search?

For more information, see the CONTRIBUTING guide.

Description

Using the client's .header() method multiple times will only send the last header if several of them with the same name.

Console Errors:

No

Screenshots: [If applicable, add screenshots to help explain your problem]

Steps to Reproduce

const client = Client.init({...});

const response = await client
    .api(`/users/${upn}/mailFolders/Inbox/messages`)
    .header('Prefer', 'outlook.body-content-type="html"')
    .header('Prefer', 'IdType="ImmutableId"')
    .get();

console.log(response);

Expected behavior:

  • Message body in HTML format
  • Immutable IDs

Actual behavior:

  • Message body in text format (default if unspecified)
  • Immutable IDs

Flipping the order of the method calls will return messages in HTML format but not with immutable IDs.

Additional Context

The method only takes a string so two values cannot be passed. For example this is not permitted:

    .header('Prefer', ['outlook.body-content-type="html"', 'IdType="ImmutableId"'])

Usage Information

Request ID - Value of the requestId field if you are receiving a Graph API error response

SDK Version - 3.0.4

  • Node (Check, if using Node version of SDK)

Node Version - v18.12

  • Browser (Check, if using Browser version of SDK)

Browser Name - [The name of Browser that you are using for SDK]

Version - [The version of the browser you are using]

Dominant language
TypeScript
Stars
833
Forks
240
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoftgraph/msgraph-sdk-javascript

All issues in microsoftgraph/msgraph-sdk-javascript

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.