自分用のメモです。。。。
-
やりたいこと
- DBのユーザ情報をJSON形式にしてスプシに出力したい
- revolution/laravel-google-sheetsのGoogle_Service_Sheetsを利用してスプシにデータを送信
-
エラー内容
{ "error": { "code": 400, "message": "Invalid JSON payload received. Unknown name \"0\" at 'data.values[0]': Cannot find field.\nInvalid JSON payload received. Unknown name \"1\" at 'data.values[0]': Cannot find field.\nInvalid JSON payload received. Unknown name \"2\" at 'data.values[0]': Cannot find field.\nInvalid JSON payload received. Unknown name \"4\" at 'data.values[0]': Cannot find field.", "errors": [ { "message": "Invalid JSON payload received. Unknown name \"0\" at 'data.values[0]': Cannot find field.\nInvalid JSON payload received. Unknown name \"1\" at 'data.values[0]': Cannot find field.\nInvalid JSON payload received. Unknown name \"2\" at 'data.values[0]': Cannot find field.\nInvalid JSON payload received. Unknown name \"4\" at 'data.values[0]': Cannot find field.", "reason": "invalid" } ], "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "field": "data.values[0]", "description": "Invalid JSON payload received. Unknown name \"0\" at 'data.values[0]': Cannot find field." } ] } ] } }
-
調査
-
encodeが違う説?
⇨utf8にencodeしても解決せず
-
content-typeをapplication/jsonにしないといけない?
⇨googleAPIが自動でやってくれてるみたい。オプションで指定も実装されてない。
-
nullをそのままJSONにしようとしてる?
⇨これでした。
-
-
原因
- nullをそのままJSONとして出力してる
-
解決法
- array_map等でnullは空文字に変換