Skip to content

Unexpected different behavior between exposed API and Unit Test APIClient request #9703

Answered by jlandercy
jlandercy asked this question in General
Discussion options

You must be logged in to vote

It seems with the format switch it works:

        response = self.client.post("/api/core/item/", data=self.payload, format="json")

But with Content-Type defined we need to encode the JSON:

        response = self.client.post("/api/core/item/", data=json.dumps(self.payload), content_type="application/json")

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@browniebroke
Comment options

@jlandercy
Comment options

@browniebroke
Comment options

@jlandercy
Comment options

Answer selected by jlandercy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #9702 on May 19, 2025 16:47.