Error : Array of objects expected in parameter formdata field

Hello Make community.

I’m having problem with the set-up of what should be (i guess) an easy HTTP request.
One of my client asked us to send new leads to their API with theses parameters:

  • POST Method
  • content-type shoud be : form-data

I’ve tried multiple settings but i always get the same message : Array of objects expected in parameter ‘formDataFields’

Here is a screen cap:

Here is the postman schema i received to help me set-up the module:
Contacts.postman_collection.json (12.2 KB)

Any idea what i’m doing wrong ?

thanks in advance !

Hi @julien_level ,

Build your JSON with the Create JSON module before you invoke the HTTP module and set the result of the JSON module as mapping variable for the fields value in your HTTP module.

Glenn - Callinetic

1 Like

When reviewing the API document, It is expecting multipart/form-data, the structure you are using looks fine, however, it is a string instead of an array expected by Integromat.

What you can do is simply set those values in the fields menu like,

You don’t need to set the disabled field as you can simply skip those, the API looks something like this in postman,

Just pass the fields required as part of the Fields by adding multiple one necessary.

1 Like

Hi @Runcorn,

I tried using this way but i keep getting the same error unfortunately.
i’m gonna try @Callinetic’s method in a moment to see if it works

HI,

the thing is my data is coming from a module (Jotform) where i already have the data as variable.
So i’m not sure i need to create a json.
Here is the situation when i map two fields:

Hi @julien_level ,

Yes, you need to create the JSON because the Fields parameter expects a mapping of an array and not a string value. You can easily map the values in the Create JSON module and use the result as mapping for the Field parameter.

Glenn - Callinetic

1 Like

@Callinetic,

thanks for you reply and time.
I did what you said but still the same error, unfortunately.

I tried with this:
SCR-20230403-tm8

or this:
SCR-20230403-tnh

and this:
SCR-20230403-toj

The string generated by the “create JSON” module looks like this:

{"ip":"192.0.4.125","city":"Paris","email":"julienlevel@test2.com","phone":"0745122356","origin":"national","zipCode":"75016","campaign":"cpa-email-nationale","customer":null,"lastname":"level","firstname":"julien","utmMedium":"cpa","utmSource":"email","requestType":"renovation","utmCampaign":"AF_National_Email_CM","request_door":true,"request_gate":true,"campaignLabel":"AF_National_Email_CM","affiliatedCode":"RN00 test","request_window":true,"request_closure":true}

should it look like this instead ?

{"ip":["80.14.152.238"],"city":["Paris"],"spam":["0"],"email":["julienlevel@test2.com"],"phone":["0745122356"],"origin":["national"],"zipCode":["75016"],"campaign":["cpa-email-nationale"],"customer":[],"lastname":["level"],"firstname":["julien"],"utmMedium":["cpa"],"utmSource":["email"],"requestType":["renovation"],"utmCampaign":["AF_National_Email_CM"],"request_door":["1"],"request_gate":["0"],"campaignLabel":["AF_National_Email_CM"],"affiliatedCode":["RN00 test"],"request_window":["0"],"request_closure":["1"]}

Thanks again !

Hi @julien_level ,

I think you’re almost there. The only thing you’re missing is the output of the JSON module to be an array.
Therefore, you’re datastructure should have an array as root element with the collection in it. Like this:

Then you can parse your JSON String with the Parse JSON module:

And finally, you can map the formDate from your Parse JSON module into the Fields parameter of your HTTP Request.

Glenn - Callinetic

Hi @Callinetic !

Thanks again for your time.

I guess i’m not far but i missing something.

here is my scenario:

Step2 : create Json

Step3 : Parse Json (i use the same data structure)
SCR-20230404-ihe

Is it normal to Create Json and then Parse with the same structure ?

Steph 4: Set variable
SCR-20230404-ii0
SCR-20230404-ii4

Step 5: HTTP

Any idea what i’m doing wrong ?

(I owe you a pack of beer for the help :sweat_smile:)

No problem, I’m glad to help. :slight_smile:
Regarding your question about creating and parsing JSON with the same structure, in theory, it is possible to leave the data structure empty in your Parse JSON module. However, when you define the structure, the available variables from the module become immediately available without running the scenario.

As for step 4, it was just an example to illustrate the process. You can actually skip that step and map the 29.formdata[] directly to the fields parameter of the HTTP request app.

Let me know if you have any other questions or need further clarification. And about the beer, don’t worry about it! I’ll happily accept a virtual one instead. :beer:

Glenn - Callinetic

2 Likes

thanks :slight_smile:

ok i removed the step 4.

I tried to map the field in the HTTP module like this:


But i get an Error : 406 Not Acceptable :face_with_peeking_eye:

When you say map, do i have to to use the map() or get() before each value ?

No, so actually how you did before.

Glenn - Callinetic

1 Like

When i do that, it says “missing value of required parameter ‘fieldType’”. Like it was empty

Jumping in between this conversation, You don’t need to use JSON Parsing and stuff for this as you are trying to map a field in Multipart FormData body and you are not using Raw Option with application/json. The JSON module is required if you are getting the full JSON with all the fields specified in Mapping Option in Map Fields or if you are getting dynamic fields/keys for the API Request Body.

Having said that if you want to use the JSON, then you need to construct the JSON object/array so it adheres to what is required in the Map option i.e it needs to be a JSON array with a payload consisting of a key, fieldType, and value as required in the Fields section of Multipart/form-data. Currently, you are passing,

[{
	"ip": "127.0.0.1"
}, {
	"city": "Paris"
}....]

which is not what is accepted in the Fields value when using map option. What you want to do is construct it such that it looks like this,

[
	{

		"key": "ip",
		"fieldType": "text",
		"value": "127.0.0.1"
	}....
]

If you are not getting dynamic fields, I still suggest you to use the unmapped option and then basically set the key, value and type by adding multiple items.

The last error message that you are getting i.e 406 corresponds to Accept Type that is being sent, not exactly sure what Make sends, but you can override by adding a Accept header with the relevant type that you are getting from the API response.

2 Likes

Hi @Runcorn and @Callinetic

It’s working ! :fireworks:

@Runcorn, I was about to reply to you in MP when i found out the mistake i was making (i think)
I guess i forgot that some paramaters where mandatory.

here how it looks in the end:

Thanks @Callinetic (and Runcorn) for the help !

it’s really great to see this kind of support here.

Yay, @julien_level Glad it is working for you. Plus, you don’t need to use the JSON parser, you can use the one that you have initially that is a mapping from the first module itself.

1 Like

OK, i’ll try to clone the scenario and give it a try.

thanks !

1 Like