Skip to content

body is JSON stringified on product projections search with POST #1039

@benoitvidis

Description

@benoitvidis

The POST variant of the product projection search expects the body to be an application/x-www-form-urlencoded string.

By default, providing a valid body leads to errors and / or parameters being omitted, because of the body being stringified by the http middleware.

An simple workaround is to set the headersWithStringBody options:

const client = new ClientBuilder()
  .withProjectKey(projectKey)
  .withMiddleware(createAuthForClientCredentialsFlow(authMiddlewareOptions))
  .withMiddleware(createHttpClient({
    ...httpMiddlewareOptions,
    headersWithStringBody: ['application/x-www-form-urlencoded'],
  }))
  .withUserAgentMiddleware()
  .build()

I suppose this content-type could be added by default.

Also, the documentation refers to a JSON string, which seems to be incorrect.

As a nice to have, is there any chance the sdk could provide a POST search accepting a body as a POJO object with the same type as its GET counterpart rather than having to manually url-encode the body?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions