whitebox-co / walmart-marketplace-api

A fully typed TypeScript, Javascript, and Node.js API library for the Walmart Marketplace API
MIT License
25 stars 10 forks source link

UNSUPPORTED_MEDIA_TYPE.GMP_ITEM_QUERY_API #157

Closed junaid33 closed 1 year ago

junaid33 commented 2 years ago

I'm using the ItemsApi like so:

const itemsApi = await walmartMarketplaceApi.getConfiguredApi(ItemsApi, {
  clientId: req.query.clientId,
  clientSecret: req.query.clientSecret,
});

const lineItems = await itemsApi.getAnItem({ id: "4390580943850", productIdType: "SKU" });

But, I'm getting an error:

  {
    code: 'UNSUPPORTED_MEDIA_TYPE.GMP_ITEM_QUERY_API',
    description: 'HTTP 415 Unsupported Media Type',
    info: 'Unsupported Media Type.',
    severity: 'ERROR',
    category: 'DATA',
    causes: [],
    errorIdentifiers: { entry: [] }
  }

I'm using the OrdersApi in the same function, could that be causing the issue?

josh-fisher commented 1 year ago

Hi @junaid33

The requestParameters of getAnItem is an ItemsApiGetAnItemRequest object, which requires properties that you are not passing in.

The correct input would be

const lineItems = await itemsApi.getAnItem({
  id: '4390580943850',
  productIdType: 'SKU',
  authorization: '',
  wMSECACCESSTOKEN: '',
  wMQOSCORRELATIONID: '',
  wMSVCNAME: ''
});

Which is how the library is generated based on the OpenApi spec that Walmart provides.

However, our library does provide a helpful util to help facilitate not having to constantly pass these in.

import { defaultParams } from '@whitebox-co/walmart-marketplace-api';

const exampleOrder = await ordersApi.getAnOrder({
  ...defaultParams,
  id: '4390580943850',
  productIdType: 'SKU',
});

In the future, I have plans to add functionality to update all these to optional during auto-generation and pass this along for the user ... for now though they must be passed in.

Feel free to re-open the issue if this doesn't work.

Hope this helps!