cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Responsive Resident
Responsive Resident

JSON formatting issues

This got marked as spam last time I tried to post, not sure why...

 

Mailchimp allows batch operations, allowing you to complete multiple operations with a single call.  Helpful when dealing with hundreds/thousands of records.  The format of the JSON is causing me a headache though.  This is what it needs to look like (confirmed working in postman)-

 

{
	"operations": 
	[
	{
	"method":"POST",
	"path": "/lists/f8b596c66e/members/",
	"body":"{
            \"email_address\": \"test1@gmail.com\",
            \"status\": \"subscribed\",            
            \"merge_fields\": {
                \"FNAME\": \"Test\",
                \"LNAME\": \"One\",
                \"ADDRESS\": {
                    \"addr1\": \"1122 Rad Dr\",
                    \"addr2\": \"\",
                    \"city\": \"Toledo\",
                    \"state\": \"OH\",
                    \"zip\": \"12345\",
                    \"country\": \"US\"
                },
                \"PHONE\": \"1233047645\",
                \"COMMERCIAL\": 1,
                \"SALUTE\": \"Dear Dan\",
                \"SOURCE\": \"CR\",
                \"ACQUIRED\": \"2019-01-01\",
                \"ARBAL\": \"\",
                \"RAU\": \"\",
                \"EXPIRES\": \"2019-07-01\",
                \"SECONDARYP\": \"1236996491\",
                \"CUSTID\": \"12345\",
                \"LOCATION\": \"1\"
            }
		}	
	"},
	{
	"method":"POST",
	"path": "/lists/f8b596c66e/members/",
	"body":"{
            \"email_address\": \"dan@tech.com\",
            \"status\": \"subscribed\",
            \"merge_fields\": {
                \"FNAME\": \"Dan\",
                \"LNAME\": \"I\",
                \"ADDRESS\": {
                    \"addr1\": \"12 Road\",
                    \"addr2\": \"\",
                    \"city\": \"Toledo\",
                    \"state\": \"OH\",
                    \"zip\": \"12345\",
                    \"country\": \"US\"
                },
                \"PHONE\": \"1233047645\",
                \"COMMERCIAL\": 1,
                \"SALUTE\": \"Dear Dan\",
                \"SOURCE\": \"CR\",
                \"ACQUIRED\": \"2019-01-01\",
                \"ARBAL\": \"\",
                \"RAU\": \"\",
                \"EXPIRES\": \"2019-07-01\",
                \"SECONDARYP\": \"1236996491\",
                \"CUSTID\": \"12345\",
                \"LOCATION\": \"1\"
            }
		}
	"}
	]
}

Looks fun, right?  

 

My problem is that it's adding quotes around part of the JSON I've generated

aia-error3.png

 

 

 

 

 

Relevant part of the flow (if it's not large enough- https://i.imgur.com/tuenGFS.png )-

The Input for Generate Record is a solid block to avoid it adding \n \t in later compose operations.

It also will not accept it as valid JSON without the whole thing inside single quotes, hence the compose action to remove those.  

 

aia-flow.png

 

The ouput from Compose 3 is what I need, I just need to stick this inside the main operations object without it adding the double quotes

 

aia-good.png

 

 

No matter how I try to do that, it will add double quotes around the entire object array (not each array item), as shown above.  Converting it to JSON works, but that strips all the escaped double-quotes, which breaks it anyways.

 

 

Ideas?

 

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Responsive Resident
Responsive Resident

I figured this out.  The issue was in trying to put the joined array (becomes a string at that point) back into an array or object variable.  That added the quotes, and I didn't notice, but it also escaped all my escaped characters.

 

So instead, just write it to a string variable instead, then pass that string variable* as the POST body.  In hindsight, rather simple.  

 

Lesson learned-  Just because you need to pass an object/array via POST (and you don't need to utilize it as an object/array inside flow anymore), doesn't mean it has to be an object/array inside Flow.  Not really a common issue though, just due to the unique batching syntax in mailchimp.

 

mc-success.png

mc-success2.png

 

 

*You must pass a fully-formed query as a variable, it won't format properly when done like you see in the HTTP body heremc4.png

 

View solution in original post

1 REPLY 1
Responsive Resident
Responsive Resident

I figured this out.  The issue was in trying to put the joined array (becomes a string at that point) back into an array or object variable.  That added the quotes, and I didn't notice, but it also escaped all my escaped characters.

 

So instead, just write it to a string variable instead, then pass that string variable* as the POST body.  In hindsight, rather simple.  

 

Lesson learned-  Just because you need to pass an object/array via POST (and you don't need to utilize it as an object/array inside flow anymore), doesn't mean it has to be an object/array inside Flow.  Not really a common issue though, just due to the unique batching syntax in mailchimp.

 

mc-success.png

mc-success2.png

 

 

*You must pass a fully-formed query as a variable, it won't format properly when done like you see in the HTTP body heremc4.png

 

View solution in original post

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Users online (8,445)