Skip to content

Commit 5f876ce

Browse files
committed
Quick fix for relative paths in batch requests
1 parent 571ba0b commit 5f876ce

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Graph.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class BatchRequest {
6161
public method: string;
6262

6363
public constructor(resource: string, method: string) {
64+
if (resource.charAt(0) !== '/') {
65+
resource = '/' + resource;
66+
}
6467
this.resource = resource;
6568
this.method = method;
6669
}
@@ -71,6 +74,10 @@ export class Batch {
7174
private scopes: string[] = [];
7275
private client: Client;
7376

77+
// this doesn't really mater what it is as long as it's a root base url
78+
// otherwise a Request assumes the current path and that could change the relative path
79+
private static baseUrl = 'https://graph.microsoft.com';
80+
7481
constructor(client: Client) {
7582
this.client = client;
7683
}
@@ -96,7 +103,7 @@ export class Batch {
96103
for (let request of this.requests) {
97104
batchRequestContent.addRequest({
98105
id: request[0],
99-
request: new Request(request[1].resource, {
106+
request: new Request(Batch.baseUrl + request[1].resource, {
100107
method: request[1].method
101108
})
102109
});

0 commit comments

Comments
 (0)