Need Help with POST Request to Voiceflow from Airtable

Hi all

I’m currently trying to upload data from Airtable to Voiceflow.

So far, I’ve successfully made a GET request to Airtable and stored the data in a variable in Postman. However, when I make my POST request, I receive the following error:

{
  "errors": {
    "data.name": {
      "message": "kb doc name required"
    }
  }
}

Here’s the body of my POST request:

json

CopyEdit

{
  "name": "Products",
  "data": [{{JSON.parse(voiceflow_data_parsed)}}]
}

I’m not sure how to resolve this issue. Do you have any insights on what might be causing this error?

Thanks in advance for your help!

To my knowledge you cannot execute JSON.parse in a variable replacement on the body. You can however leverage the pre-request script to set that as a variable then send the variable in the POST

//pre-request script
pm.variables.set("parsed", JSON.parse(voiceflow_data_parsed));

Then in the body you can set

{
  "name": "Products",
  "data": [{{parsed}}]
}

Thanks for coming to me the issue was that my post request was not in the format voiceflow expected, so with the help of ChatGPT I created the below pre-request script (which is the solution)

// ‘voiceflow_data (Is is the variable you must created to store your data from the GET request)’

let voiceflow_data_parsed = JSON.parse(pm.environment.get(“voiceflow_data”)); // Parse the data

let formattedData = {
“data”: {
“name”: “Pick your document title”,
“schema”: {
“searchableFields”: [“xxx”, “xxx”, “xxx”, “xxx”],
“metadataFields”: [“YYY”, “YYY”]
},
“items”: voiceflow_data_parsed.fields // This assumes ‘fields’ is an array of objects from your GET request
}
};

// Convert to string before sending
let finalPayload = JSON.stringify(formattedData);

// Store the formatted payload to send in the POST request
pm.environment.set(“voiceflow_payload”, finalPayload);

Also apologies if the code is inaccurate. I am new to development and I am only dipping my toe in as I am focusing on AI automation.

I am a little confused reading your response - Is the update you posted working for you or you have another issue within Postman?

I do not know the voiceflow API (please add a link and I can see if I can assist) but can help with the Postman side of things.

Yeah sorry, my follow up is the solution. Thanks again for reaching out