fix: Correct request param placement for POST endpoints#237
Conversation
Parameter-group dispatch fields (passwords, resource IDs, role slugs) were incorrectly sent as query parameters on POST requests. They belong in the JSON request body. Adds ExtraBodyParams support to WorkOSRequest and merges them into the serialized JSON at request time.
Greptile SummaryThis PR fixes parameter-group dispatch fields (passwords, resource IDs, role slugs) that were being sent as query parameters on POST requests instead of in the JSON body. It introduces Confidence Score: 5/5Safe to merge; the core fix is correct and no new P0/P1 issues were found. All changed POST endpoints use JSON content type so the No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant Service as AuthorizationService /UserManagementService
participant Request as WorkOSRequest
participant Client as WorkOSClient
participant Utils as RequestUtilities
Caller->>Service: e.g. CreateUserAsync(options)
Service->>Request: new WorkOSRequest { Method=POST, ... }
Service->>Request: AddBodyParam("password", value)
Note over Request: ExtraBodyParams["password"] = value
Service->>Client: MakeAPIRequest(request)
Client->>Client: CreateHttpRequestMessage(request)
Client->>Utils: CreateHttpContent(request)
Note over Utils: IsJsonContentType == true
Utils->>Utils: ToJsonString(options) → jsonOptions
Utils->>Utils: JObject.Parse(jsonOptions)
Utils->>Utils: foreach ExtraBodyParams → jobj[key] = JToken.FromObject(value)
Utils->>Utils: jobj.ToString() → merged JSON body
Utils-->>Client: StringContent (application/json)
Client-->>Service: HttpResponseMessage
Service-->>Caller: Typed result
Reviews (2): Last reviewed commit: "fix: Use query params for authorization ..." | Re-trigger Greptile |
ExtraBodyParams was typed as Dictionary<string, string>, so
array fields like role_slugs were comma-joined into a single
string ("admin,member") instead of serialized as a JSON array
(["admin","member"]). Widening to Dictionary<string, object>
and serializing via JToken.FromObject lets callers pass arrays
and other complex types that the API expects.
ExtraQueryParams and ExtraBodyParams were not copied into subsequent page requests, so paginated endpoints that rely on extra params (e.g. role_slugs filtering) only applied them to the first page.
Resource target fields (resource_id, resource_external_id, resource_type_slug) were sent as body params, but the authorization endpoint expects them as query params.
Summary
ExtraBodyParamsdictionary andAddBodyParammethod toWorkOSRequestfor body-level parameter injectionRequestUtilitiesnow mergesExtraBodyParamsinto the serialized JSON body at request timeAuthorizationServiceandUserManagementServiceto useAddBodyParaminstead ofAddQueryParamfor all parameter-group dispatch fieldsCloses #236
Test plan
passwordin the JSON body, not as a query parampassword_hashandpassword_hash_typein the body