Sending a «json object» through a custom app to a «json type" parameter fails, how to structure json?

Hi

Hi everyone,

I’m trying to set up an action in my MAKE custom app where I can include an optional selfEncrypt JSON object for file encryption. The selfEncrypt object contains fields for Algorithm, Key, and IV. However, I’m facing issues where the selfEncrypt value is either not mapping correctly or is invalid against my action mapping.

{
“name”: “selfEncrypt”,
“type”: “json”,
“label”: “Encryption Details”,
“required”: false,
“spec”: [
{
“name”: “Algorithm”,
“type”: “text”,
“label”: “Encryption Algorithm”,
“required”: false
},
{
“name”: “Key”,
“type”: “text”,
“label”: “Encryption Key”,
“required”: false
},
{
“name”: “IV”,
“type”: “text”,
“label”: “Initialization Vector”,
“required”: false
}
]
}

  1. How should I structure the JSON object to allow the selfEncrypt parameter to be optional?** I want it to work even if selfEncrypt is empty.
  2. What is the correct way to map this JSON structure so that it passes validation in the action mapping?

Any help or examples would be greatly appreciated!

Thanks!

Are you sure you can have a “json” field type??

The official documentation doesn’t state that “json” is acceptable.

Use a “text” type instead.

For more information, see Parameters | Make Apps

Hope this helps! Let me know if there are any further questions or issues.

@samliew


P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!

Hi, there! And thank you for the reply!

I am pretty sure it is, but I am not quite sure how it works…

Anyways, the problem or root cause problem I have is that the parameter is stringified before reaching the module action, so that when the actual API request to my service goes it is double stringified which make my endpoint fail:

I suggest using Text instead then, if you want to avoid the escaping of the content twice.

Really appreciate your suggestions! It seems however that I am still doing something wrong since even though i define it as a text in Mappable parameters (both direct as text or array with spec text), the content is beeing double escaped in the end (and one time from the scenario to the action module, before sending it to the primary api):

“name”: “annotations”,
“type”: “array”,
“label”: “Annotations”,
“required”: false,
“spec”: {
“type”: “text”
}
},

Do you know if it is possible to run custom javascript in the action module communication section (with focus on the parseJson at «annotations» just as an example)?

{
“url”: “/endpoint”,
“method”: “POST”,
“body”: {
“url”: “{{parameters.url}}”,
“annotations”: “{{parseJson(parameters.annotations)}}”, // Parsing the annotations
“fileName”: “{{parameters.fileName}}”
}
}

I think it’s best a Make employee weighs in on this, since we don’t exactly know what’s going on behind the scenes on this.

The solution was right in front of me the entire time… I just didn’t know the parsing function was active since it didn’t show up as a suggestion tip:

This will parse the incoming parameter correctly:

“content_data”: “{{parseJSON(parameters.content_data)}}”

1 Like

However, this only works on a json object, not an array with objects…

The dynamic way of doing this to the annotation is my goal:

{
“url”: “/edit_p”,
“method”: “POST”,
“body”: {
“url”: “{{parameters.url}}”,
“annotations”: [
“{{if(parameters.annotations[1], parseJSON(parameters.annotations[1]), null)}}”,
“{{if(parameters.annotations[2], parseJSON(parameters.annotations[2]), null)}}”,
“{{if(parameters.annotations[3], parseJSON(parameters.annotations[3]), null)}}”
],
“fileName”: “{{parameters.fileName}}”
}
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.