moltin / js-sdk

JavaScript & Node.js SDKs for the Elastic Path Commerce Cloud eCommerce API
http://documentation.elasticpath.com/
MIT License
173 stars 77 forks source link

`Moltin.Products.CreateRelationships(productId, 'product-variation', variationIds)` returns `{ data: null }` #287

Closed ArtyomResh closed 2 years ago

ArtyomResh commented 5 years ago

Problem

I'm trying to link product variation with product:

const productId = '797cd13e-edbb-4ee1-a47e-2d8ff9048ab7'
const variationIds = [ '44de8b4f-34ca-457c-99af-9832788c1af0' ]
const moltin = gateway({
  client_id: options.clientId,
  client_secret: options.clientSecret,
})

console.log('LLL linkProductWithVariation', productId, variationIds)

moltin.Products.CreateRelationships(productId, 'product-variation', variationIds)
  .then(response => {
    console.log('LLL linkProductWithVariation response:', response)
    return response
  })
  .catch(error => {
    console.log('LLL linkProductWithVariation ERROR', error)
    throw new Error(error)
  })

In the terminal i get:

LLL linkProductWithVariation 797cd13e-edbb-4ee1-a47e-2d8ff9048ab7 [ '44de8b4f-34ca-457c-99af-9832788c1af0' ]
LLL linkProductWithVariation response: { data: null }

Method returned { data: null } and Product didn't linked with provided Variation, which leads to the following Build Child Products method 409 error.

Expected behavior

Method should return product object, like it do when I use REST api: REST_api_response After it Product should link with provided Variation and the following Build Child Products method should build child products.

Extra

field123 commented 2 years ago

Hi 👋 @ArtyomResh

This issue is rather old I'm closing it for now. If it's still an issue in the most recent version of the SDK could you please reopen. Thank you.