Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy