Closed aravindanve closed 7 years ago
@aravindanve Are you able to share the full request payload built from the library?
If you're trying to remove all existing relationships, then UpdateRelationships
would be the right method to use.
Moltin.Products.UpdateRelationships(id, 'category')
I suspect the 500
you're seeing is because you're using CreateRelationships
with an empty payload. Let me know if this helps 🙃
Hi @ynnoj
Sorry, my mistake. I meant Moltin.Products.UpdateRelationships(id, 'category')
. I've updated the issue.
@aravindanve Can you share the payload in the request body please?
I'm using it in the backend. I need to do a quick browser test to get the request payload from the sdk. Hold on.
@ynnoj here you go! (https://runkit.com/aravindanve/moltin1)
Screenshot here: (https://pasteboard.co/GJi8oWo.png)
Looks like your hypothesis is correct! 😄
Hi @ynnoj, any idea on when this will be merged?
Hey @aravindanve. Will be merged and published this morning.
2.6.2
just published with this fix 🎉
@ynnoj Perfect! Thank You!
Hi!
Calling
await Moltin.Products.UpdateRelationships(moltinId, 'category', [])
to clear allProduct <=> Category
relationships fails with the following error:Although a
PUT
request directly placed to the endpoint works.Take a look at the code here on
Line: 8
https://github.com/moltin/js-sdk/blob/6ebcb9985221a3dfc11fdf2b4ed6bae963167594/src/utils/helpers.js#L4-L16
All other return statements return an
Array
whereas, this line returns a string. Which I suppose is again converted to JSON string withJSON.stringify(body)
resulting in"[]"
instead of[]