Forum Discussion

jfpelletier's avatar
jfpelletier
Contributor
2 years ago
Solved

Unexpected error with JSON generator

Hello!

I'm new to this board and SnapLogic in general, so this should be an easy one to resolve... 🙂

I'm creating a very simple pipeline where I use a HTTP client to read a list of ongoing, "live" projects tracked on a server, then I need to use that list to create new project shells (projects with no data except the project name) in a different system. I basically replicate projects from one system to another by using only their names.

From the HTTP client response to query the list of projects metadata I use a JSON splitter to get an array of strings for the project names only (jsonPath($, "entity.results[*].name")), then I use a JSON generator to prepare the payload for the next step, which is the creation of new projects on a different system, using the list of project names as input, and the HTTP client to POST the requests.

What I get from the JSON splitter seems valid, here's an example:

 

[
{"splitValue":"Name of the first project"},
{"splitValue":"Name of the second project"},
{"splitValue":"Name of the third project"},
{"splitValue":"Name of the fourth project"}
]

 

This is the JSON that I'm trying to create as payload for the next HTTP client step:

 

{
    "name": "${_splitValue}",
    "customerId": 771373363,
    "templateId": 86723995468
}

 

That doesn't work, here's what I'm getting as response (error message):

 
"error":
"Unexpected character ('"' (code 34)): was expecting comma to separate Object entries\n at [Source: (com.snaplogic.snaps.transform.NamedInputStream); line: 2, column: 16]"
 
Looks like my JSON is wrong, but I can't figure out what I'm doing wrong... Any idea to help me?
 
Thanks in advance!
 
JF

8 Replies

No RepliesBe the first to reply