{"record":{"id":"c3871cacec5c8dfc","repo":"JanDeDobbeleer/oh-my-posh","slug":"withings-api-error-status","errorCode":null,"errorMessage":"Withings API error: <status>","messagePattern":"Withings API error: <status>","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/segments/withings.go","lineNumber":131,"sourceCode":"\tformData := url.Values{\n\t\twithingsActionKey: {\"get\"},\n\t\t\"startdate\":       {strconv.FormatInt(start, 10)},\n\t\t\"enddate\":         {strconv.FormatInt(end, 10)},\n\t}\n\treturn w.getWithingsData(\"https://wbsapi.withings.net/v2/sleep\", formData)\n}\n\nfunc (w *withingsAPI) getWithingsData(endpoint string, formData url.Values) (*WithingsData, error) {\n\tmodifiers := func(request *httplib.Request) {\n\t\trequest.Method = httplib.MethodPost\n\t\trequest.Header.Add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\t}\n\n\tbody := strings.NewReader(formData.Encode())\n\n\tdata, err := w.Result[*WithingsData](endpoint, body, modifiers)\n\tif data != nil && data.Status != 0 {\n\t\treturn nil, errors.New(\"Withings API error: \" + strconv.Itoa(data.Status))\n\t}\n\n\treturn data, err\n}\n\ntype Withings struct {\n\tBase\n\n\tapi        WithingsAPI\n\tSleepHours string\n\tWeight     float64\n\tSteps      int\n}\n\nconst (\n\tWithingsAccessTokenKey  = \"withings_access_token\"\n\tWithingsRefreshTokenKey = \"withings_refresh_token\"\n)","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/withings.go#L113-L149","documentation":"The withings segment calls the Withings API through getWithingsData; the response body carries a Status field where 0 means success. When a response returns a non-zero Status code the segment converts it to this error string 'Withings API error: <status>'. The underlying request itself succeeded at the HTTP level; the API rejected or partially failed the logical call.","triggerScenarios":"GetMeasures, GetActivities or GetSleep call getWithingsData, the HTTP result is non-nil with Status != 0 — e.g. status 2 (invalid params), 284/293 (auth/token issues), 500-series Withings service errors — and the segment surfaces the numeric status.","commonSituations":"Expired or insufficient-scope OAuth token; querying measures for a date range with no data; Withings service outage; malformed endpoint parameters built by the segment config.","solutions":["Re-authenticate the Withings integration to refresh the OAuth token","Check the numeric status against Withings API docs and fix the corresponding request parameter","Retry later if the status is a 5xx service error","Review segment config options (measure type, date ranges) that alter the endpoint call"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// check status proactively and handle non-zero codes\ndata, err := w.Result[*WithingsData](endpoint, body, modifiers)\nif data != nil && data.Status != 0 {\n    switch data.Status {\n    case 284, 293:\n        // re-authenticate / refresh token\n    default:\n        // log and fall back to hiding the segment\n    }\n    return nil, err\n}","preventionTips":["Refresh OAuth tokens before expiry","Validate Withings API parameters against the official status code list","Add retry with backoff for 5xx statuses","Hide the segment gracefully on API errors"],"tags":["api","withings","http","network"],"backgroundTag":"api-error-status","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}