Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergeBasket requires Content-Type: application/json #114

Open
johnboxall opened this issue Feb 24, 2023 · 2 comments
Open

mergeBasket requires Content-Type: application/json #114

johnboxall opened this issue Feb 24, 2023 · 2 comments
Labels
ack Acknowledged USER STORY

Comments

@johnboxall
Copy link
Contributor

johnboxall commented Feb 24, 2023

ShopperBaskets.mergeBasket requires the content-type application/json or it fails with an HTTP 415 (unsupported media type).

The API itself is a bit odd, in that no request body is needed, so this behaviour is sorta unexpected.

Maybe our existing logic is looking for the existence of a required request payload to send this header:

{{#if (isRequestWithPayload request)}}
"Content-Type": "{{{getMediaTypeFromRequest request}}}",
{{/if}}

It might be a safe default to always send it or alternatively special case this method.

Alternatively, maybe we could request a change to the RAML. 🤷

The workaround for customers is to provide the header manually:

const mergeResponse = await new capi.ShopperBaskets(
    clientConfig
).mergeBasket({
    headers: {
        "Content-Type": "application/json",
    },
    parameters: { createDestinationBasket: true },
})

Here is a sample script showing the behaviour:

https://gist.github.com/johnboxall/eed791f95ad6636baa01269a1d178bbb

@git2gus
Copy link

git2gus bot commented Mar 8, 2023

This issue has been linked to a new work item: W-12659232

@joeluong-sfcc
Copy link
Contributor

Hi @johnboxall, thanks for bringing this to our attention. This work has been added to our backlog and we'll loop you back in when we have updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Acknowledged USER STORY
Projects
None yet
Development

No branches or pull requests

2 participants