REST flow URL with Square brackets

Gerrity
Tera Expert

Hello Community,

 

I'm trying to build a REST flow in which the URL contains an array parameter or it has a parameter with multiple name/value pairs within square and curly braces.


For example  &inputFormat=[{"givenName":"Tester", "sN":"Testperson"}]

 

I've tried using the request body such as:

 

{

   inputFormat : [

   "givenName" : "Tester",

   "sN": "Testperson"

   ]

}

 

I've also tried escaping the brackets with %5b%7b, etcc

 

How can one create a FLOW URL with these braces?  &inputFormat=[{"givenName":"Tester", "sN":"Testperson"}]

 

Thank you

1 ACCEPTED SOLUTION

Hello,

 

I've actually just resolved it. 

 

The solution is to put the inputFormat mandatory parameter within the Request Content as type Form URL-Encoded and remove the Header of "Content-type" "application/JSON"

 

So it's all working now using URL-Encoded Request Type.

 

Thanks again!

View solution in original post

3 REPLIES 3

Claude DAmico
Kilo Sage

Curly brackets denote an object which must be defined with a key and value pair for it to be considered legitimate. Square brackets denote the array which consists of comma-separated, indexed values. Combining the two just needs to follow those rules. In the example you provided as what you tried, you have an object with a single key (inputFormat) without a value pair so it is an incomplete object.

 

If I were to translate "&inputFormat=[{"givenName":"Tester","sN":"Testperson"}]" into something I would do it like this:

var inputFormat = [{
     "givenName":"Tester",
     "sN":"Testperson"
}];

This ends up being an array of length 1 containing a single object with two key/value pairs.

 

Another way to write what you were trying is this (probably what you are looking for):

{
   "inputFormat" : [{
   "givenName" : "Tester",
   "sN": "Testperson"
   }]
}

This ends up being an object with a single key/value pair where the value is an array of length 1 containing a single object with two key/value pairs.

 

It's syntax is all. Fun stuff! I hope this helps!

Claude E. D'Amico, III - CSA

Hi Claude,


Thank you very much for your response.   Your syntax makes a lot more sense!

 

However, I'm actually struggling to build the flow.    What I'm trying to do is automate AD account creation using a third party tool called ADManager Plus.  

 

The API has four mandatory parameters:

domainName, AuthToken, PRODUCT_NAME and inputFormat.

 

The URL looks like this:  

 

http://ServerName/RestAPI/CreateUser?domainName=domainname.ca&AuthToken=11111111111112222222222&PRODUCT_NAME=MODULE_NAME&inputFormat=[{"givenName":"Test","sN":"TesterGuy","templateName":"TestTemplate"}]

 

 

It's the inputFormat parameter that is causing me the issue.  If I exclude it from the "Query Parameters" section then I get an error "Mandatory Parameters are missing".  When I try to include it in the Request Content Body (in the format you write).  It still doesn't detect it as a parameter.

 

I've tried the inputFormat as a URL-Encoded request content but that doesn't work either.


I've also tried to set the Query Parameter as a variable ie: inputFormat  ${inputFormat} but this errors as it's not in JSON format.

 

Here's a screenshot of what I'm attempting:

 

 

apidemo.jpg

Here's the same with the Request Body in the format you mention:

 

API3.jpg

 

Appreciate any ideas you may have.


Thank you!

Hello,

 

I've actually just resolved it. 

 

The solution is to put the inputFormat mandatory parameter within the Request Content as type Form URL-Encoded and remove the Header of "Content-type" "application/JSON"

 

So it's all working now using URL-Encoded Request Type.

 

Thanks again!