cancel
Showing results for 
Search instead for 
Did you mean: 

Unexpected error with JSON generator

jfpelletier
New Contributor III

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
1 ACCEPTED SOLUTION

koryknick
Employee
Employee

I didn't notice before, but you don't want to have anything in the Multipart sub-type property.  Clear that $ from the expression and uncheck the expression enabler.

koryknick_0-1698779666090.png

 

View solution in original post

8 REPLIES 8

koryknick
Employee
Employee

Actually, the Content-Type should probably be "text/plain" since the values you are sending are just a string or numeric - it's not really JSON.  I believe that is what is complaining about at this point.

Let me know if that still doesn't work.

Hello again @koryknick,

Thanks for your quick input!

I'm unfortunately having the same error when I change the Content-Type:

jfpelletier_0-1698779442219.png

Kind regards,

JF

koryknick
Employee
Employee

I didn't notice before, but you don't want to have anything in the Multipart sub-type property.  Clear that $ from the expression and uncheck the expression enabler.

koryknick_0-1698779666090.png

 

Hello again @koryknick,

Thanks again, it worked this time! 🙂

The only change I made to your reply was to enabling the expression button for the "name" field and get the value from the passed list otherwise all my projects were labelled "name":

jfpelletier_0-1698780282957.png

It's all good now, thanks a lot again for your help!

Kind regards,

JF