Posting JSON array in API Connector

Hi,

I’m having some trouble and I think it’s a syntax issue.

token_values is an array of text, for which TD Postal Code String is one of the text values I’m trying to send (this is in a PUT).

Can anyone tell me how to fix this so that the syntax is right?

Here is the JSON body

{
“auth_token”:<auth_token>,
“name”:“”,
“number”:“”,
“token_values”:[“”,“”]

}

Thanks in advance!

1 Like

There’s some weird character in your text. Something in there isn’t what it seems to be.

I deleted all your spaces and replaced all your quotes until it got valid on online validators, try copying and pasting this:

{
	"auth_token": <auth_token>,
	"name": "ab",
	"number": "cd",
	"token_values": ["a", "a"]

}

Thanks, got it

I need to set a parameter for a variable:
business_hours_schedule

Below is the JSON format of how business_hours_schedule is structured (I’ve included an image right below it to give a visual of how the indentation is). I need to set the objects “day” and “times” within “schedule”

[

{
attempt_hourly_limit: 10,
connection_hourly_limit: 10,
buyer_conversion_hourly_limit: 10,
revenue_hourly_limit: 10,
schedule: [
{
day: ‘0’,
times: [“11:00…13:09”, “14:00…15:09”]
},
{
day: “1”,
times: [“11:10…18:39”, “19:10…23:39”]
}
]
}

]

VISUAL:

I also need to figure out how to write it in the body and also below for the key, like this:

Any help would be appreciated…

(Don’t know if @mishav or @mebeingken might know?)

@Jeff66 did you manage to solve this? I am also unable to crack how to specify the nested json.

I’ve also stumbled onto this problem and I figured out a solution. Let me know if it’s helpful for you @mghatiya and @Jeff66

Thanks Rico. I had managed to solve it. This is what worked for me. Exact spacings are critical.

I had covered it in this post: Facing issue with nested element parameter in API connector - #9 by mghatiya

What if i have duplicates dynamitc values

For example:

cusomter

”name” :

Type

“name ”

You mean duplicate values or duplicate keys itself?

Duplicate keys are not allowed in JSON itself as I understand. Or even if it might be allowed, it might be considering the value under latest key or something like that.

Yes , i mean duplicate keys.

for example here i have object documents ,and inside it i have duplicate keys “type”

“documents”: [

  {
    "type": "Commercial Registration",
    "number": "1234567890",
    "issuing_country": "US",
    "issuing_date": "2019-07-09",
    "expiry_date": "2021-07-09",
    "images": [
      "file_656840219076980736"
    ]
  },
  {
    "type": "Commercial license",
    "number": "1234567890",
    "issuing_country": "US",
    "issuing_date": "2019-07-09",
    "expiry_date": "2021-07-09",
    "images": [
      "file_656840219076980736"
    ]
  }

Okay, like this. These are not duplicate keys really. They are keys in different elements of array.

Here if you want multiple elements in array and have same keys in them, I think you have two options:

  1. If number of elements in your documents array is constant (say 2, as you have shown here) then you can name the dynamic values as <type1> and <type2> and so on.

  2. However, if your number of elements in documents can change, then what you do is that you test the API and initialise it with static text inside documents (i.e. one example element itself instead of any dynamic value) and reconstruct the whole array as a json element dynamically in the workflows when you invoke the APIs.

1 Like

Thank you for the clarification , now its clear

Appreciate