Skip to content

fix(ims-client): use application/x-www-form-urlencoded instead of multipart/form-data#1757

Open
ravverma wants to merge 2 commits into
mainfrom
fix/ims-form-url-encoded
Open

fix(ims-client): use application/x-www-form-urlencoded instead of multipart/form-data#1757
ravverma wants to merge 2 commits into
mainfrom
fix/ims-form-url-encoded

Conversation

@ravverma

@ravverma ravverma commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • IMS flagged that requests using multipart/form-data are breaking
  • The native FormData API (used via createFormData) causes fetch to send multipart/form-data automatically — even when noContentType: true is set, since fetch overrides the header for FormData bodies
  • OAuth/token and validate-token endpoints expect application/x-www-form-urlencoded
  • Switched createFormData to return a URLSearchParams object, which fetch encodes as application/x-www-form-urlencoded; charset=utf-8 automatically
  • This affects all imsApiCall POST requests: validateAccessToken, getServiceAccessToken, getServiceAccessTokenV3, getServicePrincipalAccessToken, getProductContextByImsOrgId

Test plan

  • Updated createFormData unit test to assert URLSearchParams output
  • Fixed includes org_id in the POST body to IMS token v3 test body matcher for the new encoding
  • Verified content-type: application/x-www-form-urlencoded in nock debug output for POST requests

🤖 Generated with Claude Code

ravverma and others added 2 commits July 1, 2026 14:27
…pplication/x-www-form-urlencoded

IMS flagged that requests using multipart/form-data are breaking.
The native FormData API sends multipart/form-data, while OAuth/token
endpoints expect application/x-www-form-urlencoded. Switch createFormData
to use URLSearchParams which natively encodes as x-www-form-urlencoded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…encoding

Nock parses x-www-form-urlencoded bodies into objects before calling
function matchers, so multipart-style string matching no longer works.
Update all body matchers to use direct property access instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

This PR will trigger a patch release when merged.

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