Writing a bulk PUT
to the CF Workers KV in Python and can’t figure out what’s wrong here. My JSON is valid as far as I can tell.
Here is the error I’m getting
Error
{ "result": null, "success": false, "errors": [ { "code": 10012, "message": "could not parse array of key/value objects from request body: 'could not unmarshal KVPair into intermediate struct: 'json: cannot unmarshal object into Go struct field kvPairJSON.value of type string''" } ], "messages": [] }
Payload
[{ “key”:“aals”, “value”:{ “sup”:{ “firo”:“aals”, “mean”:“aals”, “alpha”:[]}}}]
Code
response = requests.put(f"{CF_BASEURL}/bulk", headers=headers, data=json.dumps(payload))
Any ideas appreciated. I'm sure this is a SMH moment...
That's a useless error message, sorry about that. Workers KV values are plain bytes that may be deserialized in a Worker if needed (e.g. parsed as JSON). I think what you want to do there is just,
So that your value is encoded as a string. And then in your Worker you can,