Skip to content

Send JSON string payloads as objects - #39

Open
jsachs wants to merge 1 commit into
ulfsri:mainfrom
jsachs:codex/parse-json-string-payloads
Open

Send JSON string payloads as objects#39
jsachs wants to merge 1 commit into
ulfsri:mainfrom
jsachs:codex/parse-json-string-payloads

Conversation

@jsachs

@jsachs jsachs commented Aug 4, 2026

Copy link
Copy Markdown

Summary

Send string payloads as JSON objects when request validation is disabled.

Problem

Public client methods accept request bodies as either a dictionary or a JSON string:

client.create_incident(neris_id, body)

When Config.validate is disabled, which is the default, a JSON string was passed directly to requests using its json= argument. requests then serialized that string as a JSON string literal instead of a JSON object.

For example, this input:

body = '{"incident_number": "1234"}'

was sent as:

"{\"incident_number\": \"1234\"}"

instead of:

{
  "incident_number": "1234"
}

Endpoints that require an application/json object can reject this payload or report validation errors because the top-level value is a string rather than an object.

Fix

Parse JSON string payloads into Python objects before passing them to requests when model validation is not being used.

Dictionary payloads and validated payloads retain their existing behavior.

Tests

Added a regression test verifying that a JSON string payload is sent as a JSON object when validation is disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant