Map Array to HTTP "Make a Request" to Airtable API POST Call Not Working

After 10 hours I finally narrowed down the source of why my Airtable API POST Call was not working. Since the actual make.com tools made to post to Airtable are unusable basically.

I need further assistance however, I cannot get it to work, I have narrowed it down to an array that maybe I am not mapping properly…

1: I am Splitting Text, a social media post that starts off with the title, " THis is Post Title || This is Post Content", I am splitting that using Set Variable Module:

  1. Next, Here is the array output:

  1. Next, I attempt to map the Array output (Not sure what it’s really called) to the fields “Post Title” and “Post” in the API Call. When I first set it up the closing bracket (Not sure what it’s called is Purple) but after I run the scenario, even though the proper Post Title and Post Content TEXT IS INSIDE OF THE “Request Content” where it should be, the API Call breaks with error:

*****Error: 422 Unprocessable Entity

  • {“error”:{“type”:“INVALID_REQUEST_BODY”,“message”:“Could not parse request body”}}*****

AND, THE PURPLE CLOSING BRACKETS for the ARRAY (pieces) ARE NOW OUTLINED NOT FILLED IN PURPLE.

Here is the complete body of the API Call:

{
“records”: [
{
“fields”: {
“Post Topic”: “Luxury Custom Homes and Interiors”,
“Post Subtopic”: “Exclusive Design Consultation”,
“Post Title”: “Designing Your Dream: The Power of Personalized Design Consultation in Southeast Michigan”,
“Post”: "In the ever-evolving world of luxury custom homes, staying ahead of industry trends is paramount. Southeast Michigan is seeing a surge in personalized home design, blending cutting-edge technology with timeless aesthetics. This is where our exclusive design consultation steps in, offering bespoke solutions for those dreaming of a luxury haven tailored perfectly to their lifestyle and taste.

At Haus Custom Homes, our consultation process begins with understanding your unique preferences and needs. From selecting the ideal site to choosing materials that reflect your identity, every aspect of your luxury home planning is curated with precision. As trends lean towards sustainability and smart home technologies, our design experts ensure these elements are seamlessly integrated, enhancing both comfort and functionality.

Whether you’re looking to incorporate minimalist elegance or opulent warmth, our personalized consultation will transform your vision into a luxurious reality, making your home not just a residence, but a reflection of your highest aspirations.",
“Location”: “Southeast Michigan”,
“Post Link URL”: “https://www.hauscustomhomes.com”,
“Image Prompt”: “Realistic Photograph, Cinematic composition, Close up, Architectural consultation session, modern luxurious office, couple attentively listening to architect, detailed blueprints and 3D models, sleek minimalist decor, large windows, view of Southeast Michigan’s green landscape --ar 16:9 --v 6”,
“Image”: [
{
“url”: “https://cdn.renderform.io/AyP47SXDoOHIsP9Oomxi/results/req-284cae0d-fc68-4afc-a59c-1136e47c0a54.jpg
}
]

  }
}

]
}

  1. If I remove the mapped array parts from within the API Call body, the Request works fine… I feel like the white unfilled in bracket at the end is an indicator of why this isn’t working??

UPDATES

UPDATE 1:

I left the first part of the mapped array but removed the second part to try and isolate the issue, and now the API Call functions properly, below is the part that I removed, which is LONG TEXT and goes into a LONG TEXT FIELD inside of Airtable, so I think I need to set up the API Call differently for LONG TEXT(?)…

Screenshot 2024-07-17 at 12.53.26 p.m.

UPDATE 2:

I manually inserted LONG FORM TEXT into the API Call into the “Post:” (Field? Variable?) which may further confirm the need to handle the LONG TEXT going into a LONG TEXT FIELD in Airtable inside of the API Call.

UPDATE 3:

Now I copied and pasted the NON WORKING Request Content Body code or whatever its called, and THE API CALL WORKS, even with long text, so as usual, none of this makes any sense…

(NO LONGER) REOLVED-ISH:

This isn’t a solution. But what I did was I copied the API Call “Code” that WASNT WORKING Above, you can also see the error above, then pasted it into the HTTP “Request a Call” Module, then just replaced the text with the mapped variables from the scenario and it worked.

If this didnt work I was going to just ELIMINATE THE TEXT SPLIT, and generate the Post Title and Post Content speerately then map them to the API without the Array.

It would take 3 weeks for an expert to figure out why this isn’t working properly and that will never happen so…

BUt here is the complete body of the working API CALL:

{
“records”: [
{
“fields”: {
“Post Topic”: “{{89.Topic Randomizer}}Custom Homes Design and Build”,
“Post Subtopic”: “{{113.Subtopic}}”,
“Post Title”: “{{115.Split Post Title[1]}}”,
“Post”: “{{115.Split Post Title[2]}}”,
“Location”: “{{145.Location Randomizer}}”,
“Post Link URL”: “{{113.Link URL}}”,
“Image Prompt”: “{{139.result}}”,
“Image”: [
{
“url”: “{{130.href}}”
}
]

  }
}

]
}

Hi @ryebag

Please use a Create JSON module to generate a clean JSON structure. Here, you can map the required field values.

Once done, map the JSON generated by this module in the HTTP module to solve your issue.

Regards,
Msquare Automation - Gold Partner of Make

Book a Free Consultation | Connect Live

Explore our YouTube Channel for valuable insights and updates!

You need to escape special characters in those strings if you want to map them like this.

Special characters like double quotes and newlines need to be replaced.

e.g.: " should be replaced with \"

One way to do that is to put each variable through the “Transform to JSON” module first.

Another way is to manually replace the special characters in the string using the built-in function replace.

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

I used “Transform to JSON” got this, and it didn’t work:

JSON stringLong String
“{\n "records": [\n {\n "fields": {\n "Post Topic": "Outdoor Living Enhancements",\n "Post Subtopic": "Outdoor Lighting Solutions",\n "Post Title": "Brightening Ann Arbor: The Art of Outdoor Lighting",\n "Post": "Discover the magic of outdoor lighting techniques! At Greenhaus Landscaping, we harness the power of light to transform Ann Arbor’s outdoor spaces into enchanting nighttime sanctuaries. Whether you’re looking to enhance your garden’s evening allure, ensure safety on walkways, or create a cozy atmosphere for outdoor gatherings, we know that every light placement matters.\n\nLighting isn’t just functional; it’s about setting a mood. Imagine subtle pathway lights that guide your steps, wash lighting that gently illuminates your home’s facade, or strategic spotlighting that makes your garden’s best features pop. Our expertise in various outdoor lighting techniques not only enhances the beauty of your landscape but also extends your living space into the evening hours, offering more time to enjoy at home with family and friends. At Greenhaus Landscaping, it’s not just about lighting your yard; it’s about redefining your nighttime environment. Ready to light up your landscape? Let’s make your outdoor dreams a glowing reality.",\n "Location": "Ann Arbor, MI",\n "Post Link URL": "https://michigan.greenhauslandscaping.com/service-area/macomb-county/macomb-township-landscaping-services/\”,\n "Image Prompt": "Realistic photo of a beautifully landscaped garden pathway at twilight, featuring soft, low-level pathway lights that guide the way. The setting is just after sunset with a vibrant twilight sky. The scene is serene and inviting, with a wide-angle shot capturing the full pathway and garden elements in natural colors with warm light hues, upscale and modern landscaping, Michigan plants, high-end design, no people --ar 16:9 --v 5 --q 2",\n "Image": [\n {\n "url": "https://cdn.renderform.io/AyP47SXDoOHIsP9Oomxi/results/req-8cdd8855-add9-4486-a702-0fecac71a67d.jpg\“\n }\n ]\n\n\n }\n }\n ]\n}”

Well, looks like it worked, and now your newlines got converted to \n and double quotes " got converted to \"

Now put that variable in your third screenshot. Do the same for the rest of the variables.

If you need further assistance, please provide the following:

2. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.


(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

3. And most importantly, Input/Output bundles

Please provide the input and output bundles of the trigger/iterator/aggregator modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.

A.

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading them here will look like this:

module-1-output-bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

I did take the Transform to JSON output and use as the body for the HTTP “Make a Request” but it didn’t work.

My whole Scernario is a little bit complex, but ALL I’M TRYING TO DO IS SEND AN API REQUEST TO Airtable. Like this should be the 5th most basic thing you could do out of 200 in a make.com course and I’ve wasted like 30 hours just teying to create a record and update it in airtable.

Hi, I was just wondring if I can ask you some questions Regarding the above issue?

I mean code is code so why would my code work sometimes and not others when triggering API request to Airtable via HTTP “Make a Request”? Also, why would nobody else notice my JSON was bad nor CHATGPT nor The Airtable API Documentation, nowhere does it tell you you have to format everything with a bunch of slashes??? Its mind boggling.

I am at my wits end because now literally everything is just a guessing game of random crap. Nothing works, nowhere does it say why it doesn’t work, most people dont understand why it works, and its literally the most basic things you can do.

SOLUTION IS BELOW: PROBLEM IS THAT MAKE IS BROKEN

…Which is what I suspected the entire time. The way make sends tthe API request doesnt work. They literally mess it up so it doesnt work.

Due to the limitations of not being able to CREATE A RECORD using the AIRTABLE MODULE utilizing a dynamic base id and table id mapped from previous modules, here was the solution I created.

I simply brought in the Airtable Base ID via the WEBHOOK TRIGGER. Then rather than use a single HTTP “Make a Request” using the Airtable API to create the records, I am just utilizing one Airtable Create Record Module for each client, this way I can use the right base and table in the create record and still have it be dynamic, I set up a router and then filters between the router and the Airtabel Create Record Modules that filter based on Base ID. Seems like a completely ghetto solution but it will work for me.

1 Like

Hi @ryebag,

First, add a Create JSON module.

Under Data Structure, click Add
image

Give your Data Structure a name that makes sense.

Click Generate
image

Paste this into Sample Data box:

{
	"fields": {
		"Name": "Record Name",
		"Post": "Discover the magic... ",
		"Image": [
			{
				"url": "https://www.example.com"
			}
		],
		"Location": "Someplace, USA",
		"Post Title": "Brightening Ann Arbor...",
		"Post Topic": "Outdoor Living Enhancements",
		"Image Prompt": "Realistic photo of...",
		"Post Link URL": "https://www.example.com",
		"Post Subtopic": "Outdoor Lighting Solutions"
	}
}

Map your data into all of the fields:

In your Airtable Make an API Call module, set it up as follows:

For URL, specify everything after https://api.airtable.com/ which should is just v0/<tableid>/Post

For Body, wrap your Create JSON output as shown.
Airtable needs a single records array of collections (10 max), each structured as specified in the Create JSON module.

If you need to create multiple new records (up to 10 at a time) use Aggregate to JSON instead, specify the same Data Structure, but alter your Airtable Body slightly to remove the square brackets around the JSON Aggregator’s output:
image

Hope that makes sense and hope it helps you out.

2 Likes

I had to do it a different way for now, but thank you so much for taking the time to share this! This will be super helpful in the future