Skip to content

Path is parsed incorrectly on batch requests when adding full URL #1178

@gabrielhandeland

Description

@gabrielhandeland

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

When creating batch requests with the interface BatchRequestStep using full URLs, the URL is incorrectly parsed. The host name is stripped away, but the versioning remains.

Creating a batch request step with URL https://graph.microsoft.com/v1.0/groups, the URL on the batch request body will be /v1.0/groups. This leads to Graph treating the versioning like a part of the request path, and responding with error code 400 with error message "Resource not found for the segment 'v1.0'."

Console Errors: [Is there any console error]

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

Steps to Reproduce

  1. Create a batch request step with url path:
const batchRequestStep: BatchRequestStep = {
	id: '1',
	request: new Request(`https://graph.microsoft.com/v1.0/groups`, {
		method: 'GET',
	}),
};
  1. Create an instance of BatchRequestContent with the batch request step
const batchRequestContent = new BatchRequestContent([batchRequestStep]);
  1. Retrieve the content and log out the URL
const batchRequestBody = await batchRequestContent.getContent();
console.log(batchRequestBody.requests[0].url); 

Expected behavior: URL is parsed to /groups

Actual behavior: URL is parsed to /v1.0/groups

Usage Information

SDK Version - [SDK version you are using]

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

Node Version - v16.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions