Allow plain text response for plugin data polling

This commit is contained in:
kwlo 2025-11-01 12:59:59 -04:00
parent 80e2e8058a
commit e0323015c7
2 changed files with 31 additions and 3 deletions

View file

@ -235,9 +235,15 @@ class Plugin extends Model
}
}
// Default to JSON parsing
try {
return $httpResponse->json() ?? [];
// Attempt to parse it into JSON
$json = $httpResponse->json();
if($json !== null) {
return $json;
}
// Response doesn't seem to be JSON, wrap the response body text as a JSON object
return ['text' => $httpResponse->body()];
} catch (Exception $e) {
Log::warning('Failed to parse JSON response: '.$e->getMessage());