Skip to main content

Hello there, 

I've developed a workflow that follows these steps:

1) When a record is updated, all the product's fields are watched

2) With these watched fields, a new script will run. The main goal with this script is taking the product's information, then making a PUT request to an external JSON API by taking the product's SKU.

When I test the script, it runs successfully, but the response logs: 

{status: 400, message: "Invalid data provided"}
  1.  status: 400
  2.  message: "Invalid data provided"

Does anyone knows why this is happening? Is it an error in Airtable or in the external API server? Thanks in advance!

The code goes like this:

 

//input of modified product let inputConfig = input.config(); //Fetch for external API and JSON creation let response = await fetch(`http://.../${inputConfig.sku[0]}`, { method: 'PUT', body: JSON.stringify({ "product": { "ean": inputConfig.ean[0], "sku": inputConfig.sku[0], "name": inputConfig.name[0], "brand": inputConfig.brand[0], "short_description": inputConfig.short_description[0], "description": inputConfig.description[0], "cost_price": inputConfig.cost_price[0], "price": inputConfig.price[0], "gd_size_reference": inputConfig.gd_size_reference[0], "track_inventory": inputConfig.track_inventory[0], "available_on": inputConfig.available_on[0], "tax_category_id": inputConfig.tax_category_id[0], "stock_items_attributes": [ { "stock_location_id": inputConfig.stock_location_id[0], "count_on_hand": inputConfig.count_on_hand[0], } ], "taxon_ids": [ { "taxon_id": inputConfig.taxon_ids[0], } ], } }), headers: { 'Authorization': 'eyJh...', }, }); console.log(await response.json());

 

 

Perhaps JSON does not match the data structure of the external API.
Need to check the documentation.