def kv_create(request, kv_class, obj_pk):
    key, value, errors = get_kv(request)
    if errors:
        return HttpResponse(
            status=400, content=json.dumps(
                {'success': False, 'message': errors}
            )
        )
    obj, KVKlass = resolve_obj(kv_class, obj_pk)
    try:
        kv = KVKlass(obj=obj, key=key, value=value)
        kv.clean()
        kv.save()
        resp = {
            'status': 201,
            'content': json.dumps(
                {
                    'success': True,
                    'key': kv.key,
                    'value': kv.value,
                    'obj_uri': kv.uri,
                    'kv_pk': kv.pk
                }
            )
        }
    except ValidationError, e:
        resp = {
            'status': 400,
            'content': json.dumps({'success': False, 'message': str(e)})
        }
    return HttpResponse(**resp)
POST to:
dataset/ETHPy150Open mozilla/inventory/core/keyvalue/api.py/kv_create