Trouble with Module Request Syntax

Im creating a custom app that and trying to PATCH the “Forecast.Percent” value but, when I use quotes that make the JSON valid, I get not a valid integer response. Is there a work around for this?

{
   "url": "/quotes/{{parameters.id}}",
	"method": "PATCH",
	"qs": {},
	"body": {
		"Forecast": {
			"Percent": {{parameters.Forecast}}
		}
	},

What does parameters.Forecast contain? If it has anything other than numeric values (including a percentage symbol), it’s no longer a number. You’ll have to remove the percent symbol and convert it to a number using the built-in parseNumber function

{{parseNumber(parameters.Forecast; ".")}}

1 Like

I will clarify that, It seems that the limitation is the way that Make Requires the Quotes. Otherwise my variable tag is not recognized, nor can I save it because of Parse Error.

If I omit param var and put plain text in without quotes, This works
"Body": "Forecast": {"Percent": 50}

And This Doesnt

"Body": "Forecast": {"Percent": "50"}
"Body": "Forecast": {"Percent": "{{parameters.Percent}}"}

If only I could implement a javascript variable, without {{tag}}, Id be in business.

I think the curly brackets are only if you want to insert the variable within a string.

You can try just this:

"Percent": parameters.Forecast

2 Likes

If you need to specify a type of parameter, you need to do so in the mappable parameters tab, which contains the list of input parameters. So in your case, your mappable parameters would
look like:

[
  {
       "name": "forecast",
       "type": "number",
       "label": "Forecast"
  }
]

The {{...}} brackets are needed when you need to map a value of something, e.g. of a parameter, all parameters, body, etc.

The "..." quotation marks are used for defining a string. If you need to send a number or a boolean parameter, the quotation marks should not be used.

So in your case, if you define the parameter forecast as a number in mappable parameters, it will be sent this way (I kept your current structure):

"Forecast": {"Percent": 50}

3 Likes