{"record":{"id":"c63498d26bf1bb5f","repo":"twentyhq/twenty","slug":"request-to-url-failed-with-status-response-st","errorCode":null,"errorMessage":"Request to ${url} failed with status ${response.status} ${response.statusText}","messagePattern":"Request to (.+?) failed with status (.+?) (.+?)","errorType":"exception","errorClass":"RestApiClientError","httpStatus":null,"severity":"error","filePath":"packages/twenty-client-sdk/src/rest/index.ts","lineNumber":329,"sourceCode":"  }\n\n  private async parseResponse<TResponse>(\n    response: Response,\n    url: string,\n  ): Promise<TResponse> {\n    const rawBody = await response.text();\n    let parsedBody: unknown = undefined;\n\n    if (rawBody.trim().length > 0) {\n      try {\n        parsedBody = JSON.parse(rawBody);\n      } catch {\n        parsedBody = rawBody;\n      }\n    }\n\n    if (!response.ok) {\n      throw new RestApiClientError(\n        `Request to ${url} failed with status ${response.status} ${response.statusText}`,\n        {\n          status: response.status,\n          statusText: response.statusText,\n          url,\n          body: parsedBody,\n        },\n      );\n    }\n\n    return parsedBody as TResponse;\n  }\n\n  private async execute<TResponse>(\n    method: string,\n    path: string,\n    body: unknown,\n    requestOptions?: RestApiRequestOptions,","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-client-sdk/src/rest/index.ts#L311-L347","documentation":"Thrown by RestApiClient.parseResponse (rest/index.ts:328-337) as a RestApiClientError when `response.ok` is false. Unlike the GraphQL path, this includes structured details (status, statusText, url, body) on the error object. The body is JSON.parsed when possible, otherwise kept as raw text.","triggerScenarios":"Any REST method (get/post/put/patch/delete) where the server returns a non-2xx status: 400 for validation, 401 for auth, 403 forbidden, 404 not found, 5xx server error.","commonSituations":"Wrong path or REST resource id (404); insufficient permissions (403); malformed body (400); expired token (401); server error (500); rate limiting (429).","solutions":["Catch RestApiClientError and read `err.status`, `err.body`, and `err.url` for diagnosis.","For 401, refresh the token and retry (or register the host refresh hook).","For 404, verify the path and resource id; for 400, validate the body shape against the API.","For 5xx, check Twenty server logs and retry with backoff."],"exampleFix":"// before\nawait client.post('/rest/objects/contact', payload);\n// after\ntry {\n  await client.post('/rest/objects/contact', payload);\n} catch (err) {\n  if (err instanceof RestApiClientError) {\n    console.error(err.status, err.body);\n  }\n  throw err;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isRestApiClientError = (e: unknown): e is RestApiClientError =>\n  e instanceof RestApiClientError;","tryCatchPattern":"try {\n  const result = await client.post('/rest/objects/contact', payload);\n} catch (err) {\n  if (err instanceof RestApiClientError) {\n    // err.status, err.statusText, err.url, err.body are all available\n    if (err.status === 401) await refreshToken();\n    else if (err.status === 404) console.error('Not found:', err.url);\n    else console.error('Request failed:', err.status, err.body);\n  }\n  throw err;\n}","preventionTips":["Always catch RestApiClientError and branch on err.status.","Validate request bodies and ids before sending to avoid 400/404.","Refresh tokens proactively before expiry to avoid 401s.","Retry 5xx with exponential backoff."],"tags":["network","rest","client-sdk","http-status"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}