{"record":{"id":"e7072398f17e21e8","repo":"FlowiseAI/Flowise","slug":"graph-api-error-response-status-response-sta","errorCode":null,"errorMessage":"Graph API Error ${response.status}: ${response.statusText} - ${errorText}","messagePattern":"Graph API Error (.+?): (.+?) - (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/tools/MicrosoftOutlook/core.ts","lineNumber":158,"sourceCode":"        this.accessToken = args.accessToken ?? ''\n    }\n\n    async makeGraphRequest(url: string, method: string = 'GET', body?: any, params?: any): Promise<string> {\n        const headers = {\n            Authorization: `Bearer ${this.accessToken}`,\n            'Content-Type': 'application/json',\n            ...this.headers\n        }\n\n        const response = await fetch(url, {\n            method,\n            headers,\n            body: body ? JSON.stringify(body) : undefined\n        })\n\n        if (!response.ok) {\n            const errorText = await response.text()\n            throw new Error(`Graph API Error ${response.status}: ${response.statusText} - ${errorText}`)\n        }\n\n        const data = await response.text()\n        return data + TOOL_ARGS_PREFIX + JSON.stringify(params)\n    }\n\n    parseEmailAddresses(emailString: string) {\n        return emailString.split(',').map((email) => ({\n            emailAddress: {\n                address: email.trim(),\n                name: email.trim()\n            }\n        }))\n    }\n}\n\n// Calendar Tools\nclass ListCalendarsTool extends BaseOutlookTool {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/tools/MicrosoftOutlook/core.ts#L140-L176","documentation":"Thrown by OutlookAPI.makeGraphRequest when the fetch to Microsoft Graph returns a non-OK HTTP status. The message includes status code, statusText, and the raw response body (errorText) so the caller can see Graph's own error JSON. The request always sends Authorization: Bearer <accessToken> and JSON content type.","triggerScenarios":"Any Graph call (calendar/message actions) where response.ok is false: 401 (expired/invalid token), 403 (insufficient scopes), 404 (resource not found), 429 (throttled), 5xx (Graph outage), or 400 (malformed body/URL).","commonSituations":"Access token expired (401) — refresh cycle not running; missing Microsoft Graph scopes such as Calendars.ReadWrite or Mail.Send (403); invalid event/message id (404); throttling during bulk operations (429).","solutions":["Inspect status: 401 -> ensure refreshOAuth2Token ran and the credential has a refresh_token; 403 -> add the required Graph permission scopes and re-consent; 404 -> verify the resource id; 429 -> honor Retry-After.","Surface errorText to identify Graph's specific error code (e.g. 'code': 'InvalidAuthenticationToken').","For 5xx, retry with backoff; for persistent failures check the Microsoft 365 service health."],"exampleFix":"// before\nconst data = await outlook.makeGraphRequest(url, 'POST', body)\n\n// after: handle 401 by refreshing and retrying once\ntry {\n  return await outlook.makeGraphRequest(url, 'POST', body)\n} catch (e) {\n  if (/Graph API Error 401/.test(e.message)) {\n    await refreshOAuth2Token(credId, credData, options)\n    return await outlook.makeGraphRequest(url, 'POST', body)\n  }\n  throw e\n}","handlingStrategy":"retry","validationCode":"// Pre-flight: confirm token present and scopes likely sufficient before the call.\nif (!accessToken) throw new Error('No access token')\n// Best-effort URL/method validation before fetch\nif (!url.startsWith('https://graph.microsoft.com/')) throw new Error('URL must target Graph')","typeGuard":"const isGraphError = (e: unknown): boolean =>\n  e instanceof Error && /^Graph API Error \\d{3}:/.test(e.message)","tryCatchPattern":"try {\n  return await outlook.makeGraphRequest(url, method, body, params)\n} catch (e) {\n  if (/Graph API Error 401/.test(e.message)) {\n    await refreshOAuth2Token(credId, credData, options)\n    return await outlook.makeGraphRequest(url, method, body, params) // one retry\n  }\n  if (/Graph API Error 429/.test(e.message)) {\n    // honor Retry-After, then retry\n  }\n  throw e\n}","preventionTips":["Keep OAuth refresh enabled so 401s self-heal.","Request only the Graph scopes each action needs and re-consent when adding actions.","Implement throttling/backoff for 429 and circuit-breaking for sustained 5xx."],"tags":["microsoft","outlook","graph-api","http","network"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}