{"record":{"id":"336174a254a01851","repo":"jackwener/OpenCLI","slug":"http-r2-status-make-sure-you-are-logged","errorCode":null,"errorMessage":"HTTP ' + r2.status + ' - make sure you are logged in to Instagram","messagePattern":"HTTP ' \\+ r2\\.status \\+ ' - make sure you are logged in to Instagram","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clis/instagram/user.js","lineNumber":28,"sourceCode":"        { name: 'limit', type: 'int', default: 12, help: 'Number of posts' },\n    ],\n    columns: ['index', 'caption', 'likes', 'comments', 'type', 'date'],\n    pipeline: [\n        { navigate: 'https://www.instagram.com' },\n        { evaluate: `(async () => {\n  const username = \\${{ args.username | json }};\n  const limit = \\${{ args.limit }};\n  const headers = { 'X-IG-App-ID': '936619743392459' };\n  const opts = { credentials: 'include', headers };\n\n  // Fetch directly by username. web_profile_info is gated for some public\n  // accounts even with a valid session, while this feed endpoint still returns\n  // the same media item shape this command maps.\n  const r2 = await fetch(\n    'https://www.instagram.com/api/v1/feed/user/' + encodeURIComponent(username) + '/username/?count=' + limit,\n    opts\n  );\n  if (!r2.ok) throw new Error('HTTP ' + r2.status + ' - make sure you are logged in to Instagram');\n  const d2 = await r2.json();\n  return (d2?.items || []).slice(0, limit).map((p, i) => ({\n    index: i + 1,\n    caption: (p.caption?.text || '').replace(/\\\\n/g, ' ').substring(0, 100),\n    likes: p.like_count ?? 0,\n    comments: p.comment_count ?? 0,\n    type: p.media_type === 1 ? 'photo' : p.media_type === 2 ? 'video' : 'carousel',\n    date: p.taken_at ? new Date(p.taken_at * 1000).toLocaleDateString() : '',\n  }));\n})()\n` },\n    ],\n});\n","sourceCodeStart":10,"sourceCodeEnd":42,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/user.js#L10-L42","documentation":"The feed-by-username endpoint returned a non-OK HTTP status, most commonly 401/403 when the session is missing or Instagram rejects the request. The message deliberately hints the usual cause: not being logged in. Unlike web_profile_info, this endpoint still works for business accounts, so failures are almost always session/rate related.","triggerScenarios":"GET /api/v1/feed/user/{username}/username/?count=N returns 401/403/429 — no valid session cookie, expired login, or too-frequent calls.","commonSituations":"Running the CLI without first logging into Instagram in the driven browser; cookies expired after password change; scraping many profiles quickly and hitting throttling.","solutions":["Log into Instagram in the browser session the CLI uses, then retry.","If 429, back off and slow the request rate.","Clear and re-establish cookies after a password change or logout elsewhere.","Check the exact status code in the message to pick between auth (401/403) and rate (429) fixes."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const status = await feedStatus(username);\nif (status === 401 || status === 403) throw new Error('Login required before listing posts');","typeGuard":null,"tryCatchPattern":"try {\n  await cli.user(username);\n} catch (e) {\n  if (e.message.includes('make sure you are logged in')) {\n    console.error('Session invalid — open the browser profile and log into Instagram, then retry.');\n  } else if (e.message.includes('HTTP 429')) {\n    console.error('Rate limited — wait before retrying.');\n  } else throw e;\n}","preventionTips":["Log into Instagram before running feed commands","Rate-limit profile fetches in loops","Detect 401/403 early and refresh the session","Check the numeric status in the message to choose auth vs throttle fixes"],"tags":["instagram","http-error","authentication","rate-limit"],"backgroundTag":"http-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}