{"record":{"id":"fb07153023e4f1e3","repo":"zeroclaw-labs/zeroclaw","slug":"linkedin-create-post-with-image-failed-status","errorCode":null,"errorMessage":"LinkedIn create_post_with_image failed ({status}): {body_text}","messagePattern":"LinkedIn create_post_with_image failed \\((.+?)\\): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-tools/src/linkedin_client.rs","lineNumber":731,"sourceCode":"        if let Some(ts) = scheduled_at\n            && let Ok(dt) = chrono::DateTime::parse_from_rfc3339(ts)\n        {\n            let epoch_ms = dt.timestamp_millis();\n            body.as_object_mut().unwrap().insert(\n                \"scheduledPublishOptions\".to_string(),\n                json!({ \"scheduledPublishTime\": epoch_ms }),\n            );\n        }\n\n        let url = format!(\"{LINKEDIN_API_BASE}/rest/posts\");\n        let response = self\n            .api_request(Method::POST, &url, &creds.access_token, Some(body))\n            .await?;\n\n        let status = response.status();\n        if !status.is_success() {\n            let body_text = response.text().await.unwrap_or_default();\n            anyhow::bail!(\"LinkedIn create_post_with_image failed ({status}): {body_text}\");\n        }\n\n        let post_urn = response\n            .headers()\n            .get(\"x-restli-id\")\n            .and_then(|v| v.to_str().ok())\n            .map(String::from)\n            .unwrap_or_default();\n\n        Ok(post_urn)\n    }\n\n    async fn update_env_token(&self, new_token: &str) -> anyhow::Result<()> {\n        let env_path = self.workspace_dir.join(\".env\");\n        let content = tokio::fs::read_to_string(&env_path)\n            .await\n            .with_context(|| format!(\"Failed to read {}\", env_path.display()))?;\n","sourceCodeStart":713,"sourceCodeEnd":749,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-tools/src/linkedin_client.rs#L713-L749","documentation":"create_post_with_image POSTs the finished post (text plus the uploaded image URN) to LinkedIn's posts endpoint and bails when the HTTP status is not success, including the response body for diagnosis. It fires after image registration and byte upload already succeeded, so the problem is the post request itself: auth, author URN, visibility, or throttling.","triggerScenarios":"Expired access token (401); an author URN that does not match the token's member or organization (403); referencing an image URN owned by another entity; invalid visibility or persona fields in the post body (400); LinkedIn posting quotas (429).","commonSituations":"Posting as an organization URN with a token that only has member permissions; reusing an image URN captured from an earlier test run; long-running schedulers whose token expired between the image steps and the post step.","solutions":["Read the status and body_text first — LinkedIn returns a specific code naming the bad field (e.g. INVALID_URN) or the throttle that was hit","Confirm the author URN format (urn:li:person:{id} vs urn:li:organization:{id}) matches the token's scopes","Refresh the access token and retry the whole flow with a freshly uploaded image","On 429, back off: LinkedIn posting limits are per-member and per-organization daily quotas"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Catch anyhow errors from create_post_with_image, parse the leading status from the message, and branch: 429 -> back off and retry later; 401/403 -> refresh token and restart the flow; 4xx -> surface the body_text to the operator.","preventionTips":["Derive the author URN from the same authenticated identity that owns the image upload","Never reuse image URNs across tokens or runs","Check remaining LinkedIn post quota before scheduled bursts"],"tags":["linkedin","post-creation","http","social-api"],"backgroundTag":"http-error-response","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}