Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

POST list data returns "Received data is not a valid JSONAPI Resource Identifier Object" #838

Closed
@skonik

Description

@skonik

Hi there.

I have API endpoint which receives list of items. I need an array of items as input

    @action(detail=False, methods=['post'])
    def some_action(self, request, pk=None):
       serializer = PersonSerializer(data=request.data, many=True)

But when I try to post data in such way:

{
    "data": [
        {
            "type": "person",
            "id": "508",
            "attributes": {
                "name": "test1"
            }
        },
        {
            "type": "person",
            "id": "431",
            "attributes": {
                "name": "test2"
            }
        }
    ]
}

I always get this error:

{
    "errors": [
        {
            "detail": "Received data is not a valid JSONAPI Resource Identifier Object",
            "status": "400",
            "source": {
                "pointer": "/data"
            },
            "code": "parse_error"
        }
    ]
}

How could I pass this error?
Is it possible to send an array of data?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions