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

Trying to get product metafields give 404 #79

Open
satyasaadhak opened this issue Feb 11, 2020 · 1 comment
Open

Trying to get product metafields give 404 #79

satyasaadhak opened this issue Feb 11, 2020 · 1 comment

Comments

@satyasaadhak
Copy link

I am trying to use the /catalog/products/{product_id}/metafields endpoint to fetch metafields for the product. This product whose id I used exists, it has a metafields and the store api credentials are valid. But I keep getting this response.
Metafield Request Response

Why is this so and how to get around this problem?
I have also tried /products/{product_id}/metafields as the get request endpoint.

The code I am trying.

const bigCommerce = new BigCommerce({
  storeHash: 'xxxxxxxx',
  clientId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  accessToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
  responseType: 'json',
});

module.exports = {
  fetchProductMetafields: productId => {
    
    return bigCommerce.get(`/catalog/products/${productId}/metafields`)
    .then(metafields => {
      return metafields;
    });
  }
}

Am I doing something wrong?

@syJSdev
Copy link
Contributor

syJSdev commented May 19, 2020

I am trying to use the /catalog/products/{product_id}/metafields endpoint to fetch metafields for the product. This product whose id I used exists, it has a metafields and the store api credentials are valid. But I keep getting this response.
Metafield Request Response

Why is this so and how to get around this problem?
I have also tried /products/{product_id}/metafields as the get request endpoint.

The code I am trying.

const bigCommerce = new BigCommerce({
  storeHash: 'xxxxxxxx',
  clientId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  accessToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
  responseType: 'json',
});

module.exports = {
  fetchProductMetafields: productId => {
    
    return bigCommerce.get(`/catalog/products/${productId}/metafields`)
    .then(metafields => {
      return metafields;
    });
  }
}

Am I doing something wrong?

Hi @satyasaadhak
I think you should add the apiVersion attribute when you create the bigCommerce.

const bigCommerce = new BigCommerce({
  storeHash: 'xxxxxxxx',
  clientId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  accessToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
  responseType: 'json',
  apiVersion: "v3", // default is v2. but v2 doesn't support /catalog
});

See readme for more detail.

image

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

No branches or pull requests

2 participants